tags:

views:

1149

answers:

4

Hi, I am calling Application.Current.Shutdown method from class that is binded to xaml windows with objectdataprovider, but the application is not closing, can anyone help me to understand why? And i note that my application is not closing completely after my main window is closed, it doesn't disappear from task manager's process list. Thanks a lot.

+2  A: 

Have you created any threads to do background processing? If you have, make sure to set the .IsBackground property on them, or they can keep the app running

Orion Edwards
No, i doesn't create threads directly, may be WPF do bindings or objectdataprovider resources in other thread?
ArsenMkrt
+1  A: 

If you have multiple windows or dialogs in your application, you may need to close each one explicitly.

Close dialogs with:

_myDialog.Close();

Close all windows:

for(int i = 0; i < Application.Current.Windows.Count; i++)
{
    Application.Current.Windows[i].Close();
}
Steven Richards
I try this, it doesn't help, i realize where is the problem, the problem is that when i call shutdown() or close() the objectdataprovider execution is not terminated, I think it will be better to add a new question, what I will do now :)
ArsenMkrt
surely you could replace the for(i...) with a foreach? manually iterating over loops is so last century :-)
Orion Edwards
A: 

Envirement.Exit(0) closes the application anyway

ArsenMkrt
+1  A: 

Don't forget to add this:

private void Window_Closed(object sender, EventArgs e)
{
  Application.Current.Shutdown();
}

Hope this helps.