473,322 Members | 1,345 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,322 software developers and data experts.

Application Exit

Using VS 2003, VB.net...

I am confused about the Application.Exit 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.Exit 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.Exit
End Try
' other Sub Maincode
Call Sub1
end sub

Sub Sub1
Call Sub2
' other Sub1 code
end Sub

**** in sub 2 below, application.exit 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.Exit
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.Exit in that method, which
Applicaiton.Exit 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.Exit 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 10828
Hello, Bob:

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

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

class form1
'...
sub button1_click(...)
application.exit
end sub
'...
end class
'///

Regards.
"Bob Day" <Bo****@TouchTalk.net> escribió en el mensaje news:%2****************@TK2MSFTNGP10.phx.gbl...
| Using VS 2003, VB.net...
|
| I am confused about the Application.Exit 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.Exit 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.Exit
| End Try
| ' other Sub Maincode
| Call Sub1
| end sub
|
| Sub Sub1
| Call Sub2
| ' other Sub1 code
| end Sub
|
| **** in sub 2 below, application.exit 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.Exit
| 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.Exit in that method, which
| Applicaiton.Exit 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.Exit 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.exit will end the message loop of the form.
See this sample:

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

class form1
'...
sub button1_click(...)
application.exit
end sub
'...
end class
'///

Regards.
"Bob Day" <Bo****@TouchTalk.net> escribió en el mensaje news:%2****************@TK2MSFTNGP10.phx.gbl...
| Using VS 2003, VB.net...
|
| I am confused about the Application.Exit 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.Exit 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.Exit
| End Try
| ' other Sub Maincode
| Call Sub1
| end sub
|
| Sub Sub1
| Call Sub2
| ' other Sub1 code
| end Sub
|
| **** in sub 2 below, application.exit 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.Exit
| 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.Exit in that method, which
| Applicaiton.Exit 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.Exit 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.Exit 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/
frlrfsystemdiagnosticsprocessclasskilltopic.asp

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******@online.microsoft.com> wrote in message
news:GT****************@cpmsftngxa07.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.Exit 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/ frlrfsystemdiagnosticsprocessclasskilltopic.asp

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
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...
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). ...
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...
1
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...
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 ....
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...
3
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...
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...
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: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.