I'm encountering an exception when I call Application.Current.Shutdown in my app. The exception is:
Message
"Cannot set Visibility to Visible or call Show, ShowDialog, Close, or WindowInteropHelper.EnsureHandle while a Window is closing."
Stacktrace
For what it's worth, this app uses Prism and this is a call made via an ICommand on the Shell's viewmodel. As such:
ShellViewModel.cs (snippet)
Without over-complicating matters, the CanClose property is implemented by each screen in the application and will raise a RadWindow dialog prompting for confirmation if there are changes on that screen. Based on our implementation, all of that prompting should be complete before the Application.Current.Shutdown is called so we're not sure what's happening and we can't seem to catch this exception anywhere. It feels like it might be a race condition, but we're not sure where.
Any ideas?
Greg
Message
"Cannot set Visibility to Visible or call Show, ShowDialog, Close, or WindowInteropHelper.EnsureHandle while a Window is closing."
Stacktrace
at System.Windows.Window.VerifyNotClosing()
at System.Windows.Window.InternalClose(Boolean shutdown, Boolean ignoreCancel)
at System.Windows.Window.Close()
at Telerik.Windows.Controls.InternalWindow.WindowWithNoChromeWindowHost.Close() in c:\TB\102\WPF_Scrum\Release_WPF\Sources\Development\Controls\Navigation\Window\InternalWindow\WindowWithNoChromeWindowHost.cs:line 54
at Telerik.Windows.Controls.WindowBase.CloseHostImidiately() in c:\TB\102\WPF_Scrum\Release_WPF\Sources\Development\Controls\Navigation\Window\WindowBase.cs:line 1333
at Telerik.Windows.Controls.WindowBase.OnCloseAnimationFinished() in c:\TB\102\WPF_Scrum\Release_WPF\Sources\Development\Controls\Navigation\Window\WindowBase.cs:line 1025
at Telerik.Windows.Controls.WindowBase.PlayCloseAnimation() in c:\TB\102\WPF_Scrum\Release_WPF\Sources\Development\Controls\Navigation\Window\WindowBase.cs:line 1318
at Telerik.Windows.Controls.WindowBase.TryClose(Boolean shouldCloseHost) in c:\TB\102\WPF_Scrum\Release_WPF\Sources\Development\Controls\Navigation\Window\WindowBase.cs:line 719
at Telerik.Windows.Controls.WindowBase.Telerik.Windows.Controls.InternalWindow.IWindowDragAware.TryClose(Boolean shouldCloseHost) in c:\TB\102\WPF_Scrum\Release_WPF\Sources\Development\Controls\Navigation\Window\WindowBase.cs:line 612
at Telerik.Windows.Controls.InternalWindow.WindowWithNoChromeWindowHost.OnWindowClosing(Object sender, CancelEventArgs e) in c:\TB\102\WPF_Scrum\Release_WPF\Sources\Development\Controls\Navigation\Window\InternalWindow\WindowWithNoChromeWindowHost.cs:line 277
at System.Windows.Window.OnClosing(CancelEventArgs e)
at System.Windows.Window.InternalClose(Boolean shutdown, Boolean ignoreCancel)
For what it's worth, this app uses Prism and this is a call made via an ICommand on the Shell's viewmodel. As such:
ShellViewModel.cs (snippet)
/// <summary>
/// Gets the exit command.
/// </summary>
public
ICommand ExitCommand
{
get
{
return
new
DelegateCommand(() =>
{
// If we can close, do so...
if
(
this
.CanClose)
{
Application.Current.Shutdown();
}
});
}
}
Without over-complicating matters, the CanClose property is implemented by each screen in the application and will raise a RadWindow dialog prompting for confirmation if there are changes on that screen. Based on our implementation, all of that prompting should be complete before the Application.Current.Shutdown is called so we're not sure what's happening and we can't seem to catch this exception anywhere. It feels like it might be a race condition, but we're not sure where.
Any ideas?
Greg