1 using (BackgroundWorker bw = new BackgroundWorker()) 2 { 3 BackgroundWorker bw = new BackgroundWorker(); 4 5 bw.RunWorkerCompleted += (sender, e) => { }; 6 bw.DoWork += (sender, e) => 7 { 8 Thread.Sleep(5000); 9 } 10 bw.RunWorkerAsync("Tank"); 11 }
这种方式会导致原线程等待 新线程结束。
1 new Thread(() => 2 { 3 }).Start();
这种方式比较好