WPF手动关闭Windows窗体

Dispatcher  不能挂多线程
 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                     }));
View Code

 

posted @ 2023-08-07 17:41  Code麒麟  阅读(43)  评论(0编辑  收藏  举报