472,133 Members | 1,488 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,133 software developers and data experts.

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 3554
"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
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.