启动一个异步线程,此线程不会影响阻塞主线程运行
Task.Factory.StartNew(() =>
{
Dosomething();
});
启动多个异步线程,等多个线程都结束,才继续往下执行主线程代码
var Task1 = Task.Factory.StartNew(() =>
{
Dosomething1();
});
var Task2= Task.Factory.StartNew(() =>
{
var arg= Dosomething2();
});
var Task3 = Task.Factory.StartNew(() =>
{
Dosomething3();
});
Task.WaitAll(new Task[] {,Task1, Task2, Task3 });