473,554 Members | 2,836 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Application Exit

Using VS 2003, VB.net...

I am confused about the Application.Exi t method, where the help states "This
method does not force the application to exit." Aside from the naming
confusion, how do I force the application to exit? See **** below for my
comments/questions in a simple example.

****In Sub Main, the Application.Exi t works as expected, other sub main code
is ignored, and when the end sub is reached the application shuts down.
Sub Main
Try
' code
Catch
Application.Exi t
End Try
' other Sub Maincode
Call Sub1
end sub

Sub Sub1
Call Sub2
' other Sub1 code
end Sub

**** in sub 2 below, application.exi t does not exit the application, instead
it executes without error, but then executes the other Sub2 code, hits the
end sub, then returns to Sub1 and executes the other Sub1 code.
Sub Sub2
Try
' code
Catch
Application.Exi t
End Try
' other Sub2 code
End Sub

**** It seems that for the application to exit, you must traverse the call
stack back up to Sub Main and execute Application.Exi t in that method, which
Applicaiton.Exi t does not automatically do. I know a can create an
exception, and throw it in Sub 2, catch it in sub main, and accomplish
Application.Exi t in sub main and exit sub main and I think that would work.
But this seems like a silly way to do it.

How do I exit the application from Sub 2 above? Assume my simple example
above with no forms being displayed.

Thanks!

Bob Day
Nov 20 '05 #1
4 10844
Hello, Bob:

Application.exi t will end the message loop of the form.
See this sample:

'\\\
sub main()
application.run (new form1) 'Ends when form is closed or application.exi t (or exitthread) is called.
call (new form1).show
application.run () 'Only ends whith application.exi tthread.
'If you close the form, the program will never end.
msgbox("The message loop has ended")
end sub

class form1
'...
sub button1_click(. ..)
application.exi t
end sub
'...
end class
'///

Regards.
"Bob Day" <Bo****@TouchTa lk.net> escribió en el mensaje news:%2******** ********@TK2MSF TNGP10.phx.gbl. ..
| Using VS 2003, VB.net...
|
| I am confused about the Application.Exi t method, where the help states "This
| method does not force the application to exit." Aside from the naming
| confusion, how do I force the application to exit? See **** below for my
| comments/questions in a simple example.
|
| ****In Sub Main, the Application.Exi t works as expected, other sub main code
| is ignored, and when the end sub is reached the application shuts down.
| Sub Main
| Try
| ' code
| Catch
| Application.Exi t
| End Try
| ' other Sub Maincode
| Call Sub1
| end sub
|
| Sub Sub1
| Call Sub2
| ' other Sub1 code
| end Sub
|
| **** in sub 2 below, application.exi t does not exit the application, instead
| it executes without error, but then executes the other Sub2 code, hits the
| end sub, then returns to Sub1 and executes the other Sub1 code.
| Sub Sub2
| Try
| ' code
| Catch
| Application.Exi t
| End Try
| ' other Sub2 code
| End Sub
|
| **** It seems that for the application to exit, you must traverse the call
| stack back up to Sub Main and execute Application.Exi t in that method, which
| Applicaiton.Exi t does not automatically do. I know a can create an
| exception, and throw it in Sub 2, catch it in sub main, and accomplish
| Application.Exi t in sub main and exit sub main and I think that would work.
| But this seems like a silly way to do it.
|
| How do I exit the application from Sub 2 above? Assume my simple example
| above with no forms being displayed.
|
| Thanks!
|
| Bob Day

Nov 20 '05 #2
Hello, Bob:

Application.exi t will end the message loop of the form.
See this sample:

'\\\
sub main()
application.run (new form1) 'Ends when form is closed or application.exi t (or exitthread) is called.
call (new form1).show
application.run () 'Only ends whith application.exi tthread.
'If you close the form, the program will never end.
msgbox("The message loop has ended")
end sub

class form1
'...
sub button1_click(. ..)
application.exi t
end sub
'...
end class
'///

Regards.
"Bob Day" <Bo****@TouchTa lk.net> escribió en el mensaje news:%2******** ********@TK2MSF TNGP10.phx.gbl. ..
| Using VS 2003, VB.net...
|
| I am confused about the Application.Exi t method, where the help states "This
| method does not force the application to exit." Aside from the naming
| confusion, how do I force the application to exit? See **** below for my
| comments/questions in a simple example.
|
| ****In Sub Main, the Application.Exi t works as expected, other sub main code
| is ignored, and when the end sub is reached the application shuts down.
| Sub Main
| Try
| ' code
| Catch
| Application.Exi t
| End Try
| ' other Sub Maincode
| Call Sub1
| end sub
|
| Sub Sub1
| Call Sub2
| ' other Sub1 code
| end Sub
|
| **** in sub 2 below, application.exi t does not exit the application, instead
| it executes without error, but then executes the other Sub2 code, hits the
| end sub, then returns to Sub1 and executes the other Sub1 code.
| Sub Sub2
| Try
| ' code
| Catch
| Application.Exi t
| End Try
| ' other Sub2 code
| End Sub
|
| **** It seems that for the application to exit, you must traverse the call
| stack back up to Sub Main and execute Application.Exi t in that method, which
| Applicaiton.Exi t does not automatically do. I know a can create an
| exception, and throw it in Sub 2, catch it in sub main, and accomplish
| Application.Exi t in sub main and exit sub main and I think that would work.
| But this seems like a silly way to do it.
|
| How do I exit the application from Sub 2 above? Assume my simple example
| above with no forms being displayed.
|
| Thanks!
|
| Bob Day

Nov 20 '05 #3
Hello Bob,

Thanks for your post. I reviewed your description carefully, and I'd like
to share the following information with you:

Application.Exi t method is generally used to terminate a WinForm
application which has message pumps and application windows. According to
your code snippet, it seems to be a console application without graphical
interfaces. If so, you can call Process.Kill method to terminate the
process forcibly.

Process.Kill Method
http://msdn.microsoft.com/library/de...us/cpref/html/
frlrfsystemdiag nosticsprocessc lasskilltopic.a sp

Hope this helps.

Regards,

HuangTM
Microsoft Online Partner Support
MCSE/MCSD

Get Secure! -- www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Nov 20 '05 #4
Thanks, that was very helpful.
Bob Day

"Tian Min Huang" <ti******@onlin e.microsoft.com > wrote in message
news:GT******** ********@cpmsft ngxa07.phx.gbl. ..
Hello Bob,

Thanks for your post. I reviewed your description carefully, and I'd like
to share the following information with you:

Application.Exi t method is generally used to terminate a WinForm
application which has message pumps and application windows. According to
your code snippet, it seems to be a console application without graphical
interfaces. If so, you can call Process.Kill method to terminate the
process forcibly.

Process.Kill Method
http://msdn.microsoft.com/library/de...us/cpref/html/ frlrfsystemdiag nosticsprocessc lasskilltopic.a sp

Hope this helps.

Regards,

HuangTM
Microsoft Online Partner Support
MCSE/MCSD

Get Secure! -- www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Nov 20 '05 #5

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

Similar topics

1
8495
by: Guinness Mann | last post by:
Pardon me if this is not the optimum newsgroup for this post, but it's the only .NET newsgroup I read and I'm certain someone here can help me. I have a C# program that checks for an error condition and if it finds it it notifies the user with a MessageBox and then on the next line of code (example in a minute) it calls Application.Exit(). ...
1
17661
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). The form has a really long loop which generates approx. 700 .csv files. I do not create any threads myself (Application.exitthread() doesn't work...
6
20050
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 quite a few words in this post but the questions are actually quite similar and should be fairly quick to answer ... (1) What is Happening with...
1
3771
by: Ioannis Vranos | last post by:
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?
3
1860
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 . It closes and ends the application, and closes the NotifyIcon I have specified for this application. When I use Application.Exit it closes the form...
20
2675
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 contrast to one of them always being 'modal' (e.g., if you are moving over a picture the 'Info' form will update the (x,y) screen location in realtime...
3
2046
by: Marcel Saucier | last post by:
I have written a Console Application then created a shortcut to it on my desktop. I was able to minimize the DOS window when I click my shortcut so I dont see anymore the DOS window But, using Task Manager to run the shortcut, I am not able to get rid of (minimize) the DOS window. Is there somebody that is aware of this problem ? My...
7
4297
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 constructor - FormMain() - if this error occurs, I display a message box then call Application.Exit(). The problem is that I also need to have some code...
1
5091
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 fine. But how to do in such following scenario: if I need to give 2 option for user,1. Quit 2. Restart. In Quit option, I use Environment.Exit(0) to...
0
7497
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8010
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7530
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
1
5414
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5136
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3539
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3530
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1994
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 we have to send another system
1
1111
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.