Streaming Event Processing (C #)

I have a question about handling events with C #. I am listening to the events that class A throws. Now that the ist event is thrown, the method executes, does something. This method sometimes needs to wait for a response from data sources or the like.

I believe that event processing is synchronous, so one after another the event will be processed. Is it possible to make this asynchronous? I mean, when the method is executed, but it must wait for the data source to respond, can another event be processed?

Thank you in advance

Sebastian

+5
source share
2 answers

, , . , , , . ( # 3.5)

private void MyPotentiallyLongRunningEventHandler(object sender, SomeEventArgs e)
{
    ThreadPool.QueueUserWorkItem((state) => {
        // do something that potentially takes time

        // do something to update state somewhere with the new data
    });
}
+11

, . , .

+2

All Articles