"Ioannis Vranos" <iv*@remove.this.grad.com> wrote in message
news:uw**************@TK2MSFTNGP10.phx.gbl...
I am currently reading a chapter involving multithreading, and some sample
code calls Environment::Exit() to terminate the application with all
threads.
What is the difference from Application::Exit()? Does Application::Exit()
terminate only the main thread and background threads, and not the
foreground threads?
Application::Exit() transmits a WM_QUIT to all message pumps, informing them
to quit their processing, terminates application windows then ends
application processing. It is used in a Windows Forms application to
gracefully end it.
Environment::Exit() terminates the currently running process (and all it's
threads), then posts an exit code. This is the non-graceful way to terminate
a Windows Forms application, as any and all message that haven't been
processed yet (such as saving or uploading current changes) will be lost as
soon as the process terminates.
Thus, Application::Exit() will wait until the application is ready to
terminate, then closes it while Environment::Exit() will instantly terminate
an application..
Hope this answers your question.
-Antti Keskinen