To my understanding, an application that doesn't finish and return with a 0 error code didn't terminate correctly. Somehow though, any UWP App I make, even the very default one, finishes with error code 1 every single time. Moreover, it's main class's Dispose()
and destructor are never called. Is this expected behaviour?
To reproduce, I just made the default UWP app:
If you now run and then close the app, it seems like it's being force-quit. The last output I get is:
The thread 0x35a4 has exited with code 0 (0x0).
The thread 0x34f4 has exited with code 1 (0x1).
The program '[3376] App1.exe' has exited with code 1 (0x1).
So I take this to mean that a thread fails, and then that fails the application. Is this correct, and is this bad?
Moreover, I added the following code to the main App.xaml.cs
:
~App()
{
System.Diagnostics.Debug.WriteLine("Calling destructor");
}
// (Implement Disposable interface)
public void Dispose()
{
System.Diagnostics.Debug.WriteLine("Calling dispose");
}
Neither is ever called. What's going on?
I would like to suggest you to play with UWP lifecycles and events. As far as my understanding goes, The application when closed by the user go to the suspended mode and then it is terminated. The UWP application lifecycle goes through a series of steps wherein it even enters and leaves the background while at start or suspend. In App.Xaml.Cs you can go ahead any play with the events and understand how the application lifecycle works.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With