473,466 Members | 1,381 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Application.Exit() doesn't react

Hi,

After a given exception I would like to terminate the
program. I've been told that Application.Exit() should do
the trick, but I cant seem to make it work at all. It
compiles fine. But it doesn't seem to do anything - the
program just continues after calling the function. Should
it be in a certain scope or called via the object that
was given as an argument to Application.Run?

Please help.
Jesper.
Nov 15 '05 #1
3 5932
What about Environment.Exit()

José
"Jesper Denmark" <an*******@discussions.microsoft.com> wrote in message
news:08****************************@phx.gbl...
Hi,

After a given exception I would like to terminate the
program. I've been told that Application.Exit() should do
the trick, but I cant seem to make it work at all. It
compiles fine. But it doesn't seem to do anything - the
program just continues after calling the function. Should
it be in a certain scope or called via the object that
was given as an argument to Application.Run?

Please help.
Jesper.

Nov 15 '05 #2
Hi Jesper,

In the MSDN is clearly stated that a call to this method does not force the
application to exit, try to use a Application.DoEvents() after it as it will
process the messages in the queue.
Cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"Jesper Denmark" <an*******@discussions.microsoft.com> wrote in message
news:08****************************@phx.gbl...
Hi,

After a given exception I would like to terminate the
program. I've been told that Application.Exit() should do
the trick, but I cant seem to make it work at all. It
compiles fine. But it doesn't seem to do anything - the
program just continues after calling the function. Should
it be in a certain scope or called via the object that
was given as an argument to Application.Run?

Please help.
Jesper.

Nov 15 '05 #3
Jesper,

Are you exiting whatever event handler you are in after you make the
call? If you are on the UI thread and make the call, then you should return
from your method and then let the main message loop process the WM_QUIT
message (which is what is sent to your app when you call the Quit method).
If you keep performing processing, then the loop has to wait until your
processing is done to process the event.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Jesper Denmark" <an*******@discussions.microsoft.com> wrote in message
news:08****************************@phx.gbl...
Hi,

After a given exception I would like to terminate the
program. I've been told that Application.Exit() should do
the trick, but I cant seem to make it work at all. It
compiles fine. But it doesn't seem to do anything - the
program just continues after calling the function. Should
it be in a certain scope or called via the object that
was given as an argument to Application.Run?

Please help.
Jesper.

Nov 15 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Maziar Aflatoun | last post by:
Hi everyone, I'm writing an application that needs to quit when it encouters an error. However, Application.Exit() doesn't do anything here. Does anyone know why? public bool timerenabled {...
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...
3
by: John Wildes | last post by:
Hello All I have an application that has one form. I start the application using a Application.Run(New frmMain) command in Sub Main(). When I exit, the exit menu Item simply does a Me.Close ....
5
by: Doug Handler | last post by:
In C# 2.0, w/ the Program.cs file, i noticed that the Application.Run(new appname()) is run twice. I have in my constructor to do a check for a settings file, and if it isn't found, the...
20
by: Peter Oliphant | last post by:
How does one launch multiple forms in an application? Using Photoshop as an example, this application seems to be composed of many 'disjoint' forms. Yet, they all seem somewhat 'active' in...
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;
7
by: Jay | last post by:
In my C# code, I'm attempting to display a message box then quit the win form application I'm writing if a certain type of error occurs when the application starts up. In the main form's...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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,...
1
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
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.