Let's assume I have an async method, which notifies me via an event when a certain change happens. Currently I'm able to assign the event's information to a static variable like this:
static EventInfo result = null;
// eventHandler, which assigns the event's result to a locale variable
void OnEventInfoHandler(object sender, EventInfoArgs args)
{
result = args.Info;
}
resultReceived += OnEventInfoHandler;
// async method call, which fires the event on occuring changes. the parameter defines on what kind of change the event has to be fired
ReturnOnChange("change");
But I would like to assign the callback value to a locale variable like this:
var result_1 = ReturnOnChange("change1");
var result_2 = ReturnOnChange("change2");
So I could distinguish between different method calls and their corresponding events, without using any static fields.