|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Same event fired from 2 different threads..?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() { } On 26 Nov., 16:38, t***@agramkow.com wrote:
Show quote > Hi Sorry... Here is the rest..> > 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 - //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 The event-handler is executed in the same thread as where the event is > each other. > > How is this hande by the CLR? Are the calls queued? fired. So in your example, the code in the event-handler will execute simultaneously in two different threads. |
|||||||||||||||||||||||