public class Program
{
//定义一个为委托
public delegate void Entrust(string str);
public static Action<string> callback1 = null;
static void Main(string[] args)
{
callback1 = ((string str) => { Console.WriteLine(str); });
//Lamuda表达式
Thread th = new Thread(Fun);
th.IsBackground = true;
th.Start();
Console.ReadKey();
}
private static void Fun()
{
for (int i = 1; i <= 10; i++)
{
Console.WriteLine("子线程循环操作第 {0} 次", i);
Thread.Sleep(500);
}
Action<string> callback = callback1 as Action<string>;
callback("我是子线程,我执行完毕了,通知主线程");
}
}