Same event fired from 2 different threads..?

  • Thread starter Thread starter tjo
  • Start date Start date
T

tjo

Hi

I have a short question regards event i C#.

I have two C# threads. The can both fire the same event idepended of
each other.

How is this hande by the CLR? Are the calls queued?

Thread1()
{

}
 
Hi

I have a short question regards event i C#.

I have two C# threads. The can both fire the same event idepended of
each other.

How is this hande by the CLR? Are the calls queued?

Thread1()
{



}- Skjul tekst i anførselstegn -

- Vis tekst i anførselstegn -

Sorry... Here is the rest..

//Thread class
Thread1()
{
....
if(OnPacket != null)
OnPacketr();
...
}


Thread2()
{
....
if(OnPacket != null)
OnPacketr();
...
}


// Main class
Main()
{
.....
myClass.OnPacket += new OnPacket(eventHandler);
}

eventHandler()
{

}

If the Thread1 and Thread2 fires the event at the same time, how does
the CLR handle this?
 
I have two C# threads. The can both fire the same event idepended of
each other.

How is this hande by the CLR? Are the calls queued?

The event-handler is executed in the same thread as where the event is
fired. So in your example, the code in the event-handler will execute
simultaneously in two different threads.
 
Back
Top