Create a dictionary and add the values to it at different projects of a solution and flush it to Azure


  • Hi,

    I am writing this question just to understand whether my requirement possibly can be done or not. Please assist. 

    I am very new to Application Insights and trying to implement it my current projects. I have created a telemetry client objects and initialized. I have wrapped all the basic methods of telemetry client like Traces, Custom Events, Exceptions in a separate method so that I don't want to call the telemetry client method directly & Also we need to install the App Insights packages in the projects which we use. 

    I have a plan to create a dictionary and add the key & value pair to the same dictionary across my working application & once my work done, can I flush the values flooded in the dictionary to Azure by "telemetryClient.Flush();" 

    But I am not sure whether this can be done. It will be great help if somebody clarifies the below queries. 

    1. I am creating a public dictionary and adding the values to it across all class files. Once the work is done, I need to flush the values which dictionary is holding currently.

    2. My application works Asynchronously. My app is data processing system. It will pick the chunk of data first & then formats it and stores in our local machine. It will starts to pick the chunks of data for every 5 seconds. In this case, how can I differentiate or add the values to dictionary for different chunks. Do I need to create a new dictionary for every chunk?

    I am not sure whether my above questions makes sense. Just help me understand this. 

    Creating a dictionary:

    ParentClass: /* static */
    public static Dictionary<stringstring> SampleDictionary = new Dictionary<stringstring>();

     In this class I have a method which will add the values to the dictionary.


    public static void AddItems(string _key, string _values)         {             SampleDictionary.Add(_key, _values);         }


    I will call AddItems() anywhere like this & will do it across the class files. After adding the items, how to flush this?

    ParentClass.AddItems("SampleKey", "SampleValue");

    Also, how to implement this in Asynchronously?

    Thanks in advance!

    Thursday, December 20, 2018 4:25 AM

All replies