Exemplo n.º 1
0
 /// <summary>
 /// The trigger of MyEvent class.
 /// </summary>
 public void Fire(MyEventArgs e)
 {
     //After rigorous testing I found this was the simplest way to solve the classic event race condition
     //I rewired RaiseEvent and EventMarshal to increase race condition tendancy, and began looping
     //only itterating between 20 and 200 times I was able to observe the race condition every time,
     //with this lock in place, I have itterated 10's of thousands of times without failure.
     lock (someEventLock)
         somethingHappened.RaiseEvent(MyEventSender, e);
     Thread.Sleep(1);     //This is optional, but may make things more fluid.
 }
 /// <summary>
 /// The trigger of MyEvent class.
 /// </summary>
 public void Fire(MyEventArgs e)
 {
     somethingHappened.RaiseEvent(MyEventSender, e);
     Thread.Sleep(1);     //This is optional, but may make things more fluent.
 }