I am having some confusion regarding events and synchronization. I am working in .Net Core 3.1. I multiple event handlers that need to perform asynchronously from each other, but after doing some research online I am not sure whether or not these operations are asynchronous or not, which they need to be. Can somebody with knowledge on asynchronous operations in C# give me some guidance? Here is the basic set up:
public class ReceiveClass {
public EventHandler<MyEventArgs> OnReceive;
public void Receive(object myData)
{
// some processing
OnReceive?.Invoke(new MyEventArgs { Data = myData });
}
}
The Receive method may be invoked asynchronously, and the eventhandler may have many listeners. Will the listeners be invoked asynchronously, or synchronously? If synchronously, how can I make it asynchronous?