t = new Thread(new ThreadStart(delegate { Play(sender, e); Console.WriteLine("Play ended."); })); t.Start();
private void Play(object sender, EventArgs e) { Console.WriteLine("InvokeRequired = " + InvokeRequired); if (InvokeRequired) { Invoke(new PlayDelegate(Play), sender, e); return; } }
这里应该使用 Invoke,避免使线程t死掉