Thread tr0 = new Thread(new ParameterizedThreadStart((obj1) => { lock (aaa) { Thread.Sleep(3000); this.Dispatcher.Invoke(new Action(() => { Thread.Sleep(3000); })); } })); tr0.IsBackground = true; tr0.Start(); Thread.Sleep(3000); lock (aaa) { Thread.Sleep(3000); }
在线程里面访问主线程,主线程和线程共用一把锁互相等待导致死锁。