C#的线程_任务

class Program {        static void ThreadMethod() {            Console.WriteLine("任务开始");            Thread.Sleep(2000);            Console.WriteLine("任务结束");        }        static void Main(string[] args) {            //Task t = new Task(ThreadMethod);//传递一个需要线程去执行的方法            //t.Start();            //TaskFactory tf = new TaskFactory();            //Task t = tf.StartNew(ThreadMethod);            Console.WriteLine("Main");            Console.ReadKey();        }    }

猜你喜欢

转载自blog.csdn.net/qq_39646949/article/details/123080312