WPF手动关闭Windows窗体
Dispatcher 不能挂多线程
View Code
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
1 Application.Current.Dispatcher.BeginInvoke(new Action(() => 2 { 3 try 4 { 5 int count = 0; 6 foreach (Window window in Application.Current.Windows) 7 { 8 if (window.GetType() == typeof(LogInWindow)) 9 { 10 this.Num=10; 11 window.Close(); 12 } 13 } 14 } 15 catch (Exception ex) 16 { 17 NLogger.LogError(ex); 18 } 19 }));