【发布时间】:2014-06-05 02:58:30
【问题描述】:
我正在尝试关闭 WPF 中的所有 Windows。这些窗口都是在不同的线程中产生的。
这是我的功能:
`
private void Button_Click(object sender, RoutedEventArgs e)
{
this.Dispatcher.Invoke(() =>
{
foreach (Window window in Application.Current.Windows)
{
if (window == Application.Current.MainWindow)
window.Close();
}
//MessageBox.Show(varWindows.ToString());
//for (int intCounter = App.Current.Windows.Count; intCounter > 0; intCounter--)
// App.Current.Windows[intCounter - 1].Hide();
});
}`
【问题讨论】:
-
哪一行出现错误?
标签: c# .net wpf multithreading