This is a migrated thread and some comments may be shown as answers.

Exception on Application.Current.Shutdown()

1 Answer 291 Views
Window
This is a migrated thread and some comments may be shown as answers.
Greg
Top achievements
Rank 1
Greg asked on 17 Dec 2012, 06:04 PM
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
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

1 Answer, 1 is accepted

Sort by
0
Vladi
Telerik team
answered on 20 Dec 2012, 11:57 AM
Hello Greg,

We are not aware of such issues in the control and we tried to reproduce it but to no avail.

Could you open a support ticket and send us a project that recreates the issue in order for us to observe it at our side and see what could be the cause of it?

Kind regards,
Vladi
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Tags
Window
Asked by
Greg
Top achievements
Rank 1
Answers by
Vladi
Telerik team
Share this question
or