473,395 Members | 2,795 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 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 3741
"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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Brendan Miller | last post by:
I am trying to close my application using Application.exit() in the frmMain_Closing event. When the form closes the process does not. My application only has one form (no other classes either). ...
4
by: Chuck | last post by:
Hello everybody, I need to abort execution during start up, while the constructor called by Application.Run is executing. If the database fails to connect during my application's startup I...
6
by: orekin | last post by:
Hi There I have been trying to come to grips with Application.Run(), Application.Exit() and the Message Pump and I would really appreciate some feedback on the following questions .. There are...
22
by: Shelby | last post by:
Hi, I used System.Windows.Forms.Application.DoEvents() in a loop to handle user click close button . Private Sub btnclose_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)...
12
by: Pete Smith | last post by:
Which is the appropriate one to use in the above choice? VB.Net. .Net Framework 1.1 Thank you, Pete
2
by: cweeks | last post by:
When the user clicks on my Exit menu command I call Close() followed by Application.Exit(). The GUI goes away as expected but the process is still listed in Task Manager. What do I need to do to...
4
by: vul | last post by:
I start the application with Application.Run(New MDIMain) in Sub Main. MDIMain is the mdi form which loads and then calls Login form. I'm using Application.Exit to terminate my VB 2005 application...
4
by: JIM.H. | last post by:
Here is the code I am having problem: static void Main(string args) { bool isPar = false; if ((args.Length == 1)) { if ((args(0).ToUpper() == "MYPAR")) { isPar = true;
1
by: =?Utf-8?B?VGFvZ2U=?= | last post by:
Hi All, When I use applcation.exit() in winForm application, the form closed, but the process is still going!! ( The debug process is still running if debug in VS IDE). Environment.Exit(0) works...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.