hello,
can any one tell me what happens when we use the statement :
Application.Current.Shutdown();
I am using this statement many a times in my code depending on if certain conditions are satisfied . however i am concern about disposing all the resources (specially some audio stream which i opened ) properly . does this happen in the background when we use this code?
thank you
Loading

VulpesPosted Dec 21, 2014, 2:55 PM
It can only be called from the thread which created the application in the first place.
When a managed application is shut down, the CLR will automatically clean up any managed resources.
It won't directly clean up any unmanaged resources as it knows nothing about these.
However, if objects which utilize unmanaged resources implement IDisposable and have properly implemented the disposable pattern then, when their destructor runs, it should ensure those resources are cleaned up if the Dispose() method has not been called already. Normally, the destructors of all active objects (if they have one) will be called when a managed application shuts down. However, there is a time limit within which all this must happen and in rare circumstances there might not be time for all destructors to be called.
As a final safeguard, when a process ends, the operating system itself should ensure that any resources it was using are released for use by other processes.
So, the short answer is that you shouldn't have anything to worry about.
However, if it were me, I'd be inclined to to call Dispose() on any objects which use unmanaged resources before I call Application.Current.Shutown to make absolutely sure there won't be a problem.
Sanju SinghPosted Dec 21, 2014, 11:05 PM