Created
February 13, 2012 08:32
-
-
Save wsky/1815043 to your computer and use it in GitHub Desktop.
clr event
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[TestClass] | |
public class UnitTest1 | |
{ | |
[TestMethod] | |
public void TestMethod1() | |
{ | |
var f = new EventFactory(); | |
f.Raised += (o, e) => { Thread.Sleep(100); Trace.WriteLine(1, Thread.CurrentThread.Name); }; | |
f.Raised += (o, e) => { Thread.Sleep(200); Trace.WriteLine(2, Thread.CurrentThread.Name); }; | |
f.Raised += (o, e) => { Thread.Sleep(300); Trace.WriteLine(3, Thread.CurrentThread.Name); }; | |
f.Raised += (o, e) => { Thread.Sleep(400); Trace.WriteLine(4, Thread.CurrentThread.Name); }; | |
f.Raised += (o, e) => { Thread.Sleep(500); Trace.WriteLine(5, Thread.CurrentThread.Name); }; | |
Trace.WriteLine("begin", Thread.CurrentThread.Name); | |
f.Raise(); | |
Trace.WriteLine("end", Thread.CurrentThread.Name); | |
} | |
//public delegate void EventHandler(EventArgs args); | |
public class EventFactory | |
{ | |
public event EventHandler Raised; | |
public void Raise() | |
{ | |
this.Raised(this, new EventArgs()); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
TestRunnerThread: begin
TestRunnerThread: 1
TestRunnerThread: 2
TestRunnerThread: 3
TestRunnerThread: 4
TestRunnerThread: 5
TestRunnerThread: end