469,592 Members | 1,795 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,592 developers. It's quick & easy.

Application::Exit() vs Environment::Exit() in .NET multithreading

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?
Nov 17 '05 #1
1 3437
"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
Nov 17 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Chuck | last post: by
12 posts views Thread by Pete Smith | last post: by
4 posts views Thread by vul | last post: by
4 posts views Thread by JIM.H. | last post: by
1 post views Thread by =?Utf-8?B?VGFvZ2U=?= | last post: by
4 posts views Thread by guiromero | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.