//执行回调函数
static void Main(string[] args)
{
UPPER = 1000;
Thread thread1=new Thread(sops);
thread1.Name = "thread1";
thread1.Start();
Thread thread2=new Thread(sops);
thread2.Name = "thread2";
thread2.Start();
Console.ReadLine();
}
static void Callback(object o)
{
for (int i = 0; i < UPPER; i++)
{
Console.WriteLine(o);
}
}
static void sops()
{
for (int i = 0; i < UPPER; i++)
{
Console.WriteLine("hello this data is {0}++++++++++++++++{1}", Thread.CurrentThread.Name, i);
}
Console.WriteLine( Thread.CurrentThread.Name+"over");
ExecutionContext.Run(ExecutionContext.Capture(), new ContextCallback(Callback), Thread.CurrentThread.Name);
}
public static int UPPER { get; set; }