2014-03-26 65 views
0

我提醒使用者该过程完成类似工作:WPF窗口关闭不点击

var result = MessageBox.Show("Completed!!", "Upload Status", MessageBoxButton.OK, MessageBoxImage.Information); 

if (result == MessageBoxResult.OK) 
{ 
    result = MessageBox.Show("Do you want to Quit the application ?", "Quit Application", MessageBoxButton.YesNo, MessageBoxImage.Question); 

    if (result == MessageBoxResult.Yes) 
    { 
     OpenWebSite(); 

     // I want to close the message box and complete application. 

    } 
} 

如果我写this.Close..It是给予例外,所以我写的是这样的:

Dispatcher.BeginInvoke(new Action(() => { this.Close(); })); 

依然页面经过两次点击[是]按钮,该按钮使得在OpenWebSite();被称为两次只关闭。 ...

任何想法是什么造成这种情况?

+0

请告诉我们,被抛出的异常类型,什么你'OpenWebSite()'方法是身体 – mwrichardson

回答

0

使用Application.Current.Shutdown()