C# Thread 多种写法总结

 

 

    //csharp 1.0,             //使用委托,需要使用已定义好的函数             new Thread(new ThreadStart(MyFun)).Start();

            //csharp 2.0,             //省略委托,MyFun自动实例化为ThreadStart委托             new Thread(MyFun).Start();

            //匿名方法             new Thread(new ThreadStart(delegate() { Console.WriteLine("my function"); })).Start();

            //匿名方法,省略参数列表             new Thread(new ThreadStart(delegate { Console.WriteLine("my function"); })).Start();

            //匿名方法,自动转委托             new Thread(delegate() { Console.WriteLine("my function"); }).Start();

            //csharp 3.0             //Lambda表达式             new Thread(() => { Console.WriteLine("my function lamda "); this.label1.Text = "LAMBDA"; }).Start();

posted @ 2019-05-15 10:04  万事如意-  阅读(57)  评论(0编辑  收藏