Home All Groups Group Topic Archive Search About

Application.Exit or End

Author
30 Jan 2006 9:41 PM
Pete Smith
Which is the appropriate one to use in the above choice?
VB.Net. .Net Framework 1.1
Thank you,
Pete

Author
30 Jan 2006 10:08 PM
Chris
Pete Smith wrote:
> Which is the appropriate one to use in the above choice?
> VB.Net. .Net Framework 1.1
> Thank you,
> Pete
>
>

As far as I know both should be avoided unless you have a specific
reason to use it.  In most cases closing the forms will exit the
program.  Why are you trying to use either?

chris
Author
30 Jan 2006 11:18 PM
Pete Smith
My understating is by calling the above statements will close the
application properly. Like releasing all the resources....  etc.

That is the reason why I am calling the above statements.

Pete


Show quoteHide quote
"Chris" <no@spam.com> wrote in message
news:eLoKcmeJGHA.3492@TK2MSFTNGP09.phx.gbl...
> Pete Smith wrote:
> > Which is the appropriate one to use in the above choice?
> > VB.Net. .Net Framework 1.1
> > Thank you,
> > Pete
> >
> >
>
> As far as I know both should be avoided unless you have a specific
> reason to use it.  In most cases closing the forms will exit the
> program.  Why are you trying to use either?
>
> chris
Author
30 Jan 2006 11:25 PM
Herfried K. Wagner [MVP]
"Pete Smith" <PeteSmit***@hotmail.com> schrieb:
> My understating is by calling the above statements will close the
> application properly. Like releasing all the resources....  etc.
>
> That is the reason why I am calling the above statements.

Both will release resources, but custom cleanup code may not be executed!
Could you describe the design of your application in more detail and where
you are calling 'End'/'Application.Exit'?

--
M S   Herfried K. Wagner
M V P  <URL:http://dotnet.mvps.org/>
V B   <URL:http://classicvb.org/petition/>
Author
31 Jan 2006 1:25 AM
Pete Smith
Application is basically gets the data from the database and prints in a
particualr format. When the user clicks the "Exit" button or "X" on the
right top of the windows form, the application will close.
Thank you,
Pete
..



Show quoteHide quote
"Herfried K. Wagner [MVP]" <hirf-spam-me-here@gmx.at> wrote in message
news:Oprp8RfJGHA.312@TK2MSFTNGP09.phx.gbl...
> "Pete Smith" <PeteSmit***@hotmail.com> schrieb:
> > My understating is by calling the above statements will close the
> > application properly. Like releasing all the resources....  etc.
> >
> > That is the reason why I am calling the above statements.
>
> Both will release resources, but custom cleanup code may not be executed!
> Could you describe the design of your application in more detail and where
> you are calling 'End'/'Application.Exit'?
>
> --
>  M S   Herfried K. Wagner
> M V P  <URL:http://dotnet.mvps.org/>
>  V B   <URL:http://classicvb.org/petition/>
>
Author
31 Jan 2006 7:09 AM
Herfried K. Wagner [MVP]
"Pete Smith" <PeteSmit***@hotmail.com> schrieb:
> Application is basically gets the data from the database and prints in a
> particualr format. When the user clicks the "Exit" button or "X" on the
> right top of the windows form, the application will close.

Simply call 'Me.Close()' inside the form instead of calling 'End' or
'Application.Exit'.

--
M S   Herfried K. Wagner
M V P  <URL:http://dotnet.mvps.org/>
V B   <URL:http://classicvb.org/petition/>
Author
30 Jan 2006 11:26 PM
Ken Halter
"Pete Smith" <PeteSmit***@hotmail.com> wrote in message
news:urSxiNfJGHA.604@TK2MSFTNGP14.phx.gbl...
> My understating is by calling the above statements will close the
> application properly. Like releasing all the resources....  etc.
>
> That is the reason why I am calling the above statements.
>
> Pete

If the .Net version of 'End' works anything like the VB6 version, use
anything else. In VB6, sure, it stops the app but in a way that's similar to
shutting your car off while driving. iow, it "yanks the plug" on the app,
possibly leaving automation objects hanging around waiting for task manager
intervention.

--
Ken Halter - MS-MVP-VB (visiting from VB6 world) - http://www.vbsight.com
Please keep all discussions in the groups..
Author
31 Jan 2006 12:56 AM
Dennis
What do you do if you start you application from a sub main and open a form
within sub main?
--
Dennis in Houston


Show quoteHide quote
"Chris" wrote:

> Pete Smith wrote:
> > Which is the appropriate one to use in the above choice?
> > VB.Net. .Net Framework 1.1
> > Thank you,
> > Pete
> >
> >
>
> As far as I know both should be avoided unless you have a specific
> reason to use it.  In most cases closing the forms will exit the
> program.  Why are you trying to use either?
>
> chris
>
Author
31 Jan 2006 6:28 AM
CMM
"Dennis" <Den***@discussions.microsoft.com> wrote in message
news:EB1DF272-5997-4A01-A8DA-453935FFB876@microsoft.com...
> What do you do if you start you application from a sub main and open a
> form
> within sub main?

You close the form (Unload Me).
Author
31 Jan 2006 7:47 AM
CMM
<shame> Oops... I had a VB.Classic flashback.... it's Me.Close. Just like H.
Wagner said in another post.


Show quoteHide quote
"CMM" <cmm@nospam.com> wrote in message
news:Oz22T%23iJGHA.3000@TK2MSFTNGP14.phx.gbl...
> "Dennis" <Den***@discussions.microsoft.com> wrote in message
> news:EB1DF272-5997-4A01-A8DA-453935FFB876@microsoft.com...
>> What do you do if you start you application from a sub main and open a
>> form
>> within sub main?
>
> You close the form (Unload Me).
>
>
Author
31 Jan 2006 7:22 AM
Cor Ligthert [MVP]
Pete,

In C# (and other languages) is used a Shared Sub Main as starting point of a
program

In VB Net as in VB6 you have the choise between using that Sub Main or using
the inbuild one in your main-form. (Herfried uses forever that Sub Main in
his samples, I use forever that MainForm (form1).

You would never use End for the reason as Ken Halter has explained.

With a Sub Main you would use
application.exit

With a mainform you would use
me.close

I hope this helps,

Cor
Author
1 Feb 2006 12:22 PM
José_Manuel_Agüero
Hello group,

Let me give my opinion about how to properly close a Windows Forms application:

If you haven't a Sub Main, that is, your starting object inherits from System.Windows.Forms.Form, you should finish by closing the main form. You can use Application.Exit (or ThreadExit) or even Environment.Exit, but it won't fire events like Closing or Close.

If you have a Sub Main, you can use Application.Run to start one or more consecutive message pumps. You can do it in two ways:
· Using Application.Run(): You have to quit from the message pump by executing Application.Exit (or ThreadExit if you use multiple threads). The inconvenient has been noted above.
· Using Application.Run(ApplicationContext) or Application.Run(Form): This way you work just like when you have one main form: closing the form will finish the message pump. Additionally, if you use an ApplicationContext you can change the ApplicationContext.MainForm at any time, efectively changing your application's main form (the form that will end the message pump when closed). You can still use Application.Exit or ThreadExit to quit without invoking further events.

Regards.


Show quoteHide quote
"Pete Smith" <PeteSmit***@hotmail.com> escribió en el mensaje news:umifBXeJGHA.424@TK2MSFTNGP12.phx.gbl...
| Which is the appropriate one to use in the above choice?
| VB.Net. .Net Framework 1.1
| Thank you,
| Pete
Author
2 Feb 2006 9:33 PM
Pete Smith
Thank you for your thoughts.
-Pete


"José Manuel Agüero" <chema012 en hotmail.com> wrote in message
news:OJZm0oyJGHA.2036@TK2MSFTNGP14.phx.gbl...
Hello group,

Let me give my opinion about how to properly close a Windows Forms
application:

If you haven't a Sub Main, that is, your starting object inherits from
System.Windows.Forms.Form, you should finish by closing the main form. You
can use Application.Exit (or ThreadExit) or even Environment.Exit, but it
won't fire events like Closing or Close.

If you have a Sub Main, you can use Application.Run to start one or more
consecutive message pumps. You can do it in two ways:
· Using Application.Run(): You have to quit from the message pump by
executing Application.Exit (or ThreadExit if you use multiple threads). The
inconvenient has been noted above.
· Using Application.Run(ApplicationContext) or Application.Run(Form): This
way you work just like when you have one main form: closing the form will
finish the message pump. Additionally, if you use an ApplicationContext you
can change the ApplicationContext.MainForm at any time, efectively changing
your application's main form (the form that will end the message pump when
closed). You can still use Application.Exit or ThreadExit to quit without
invoking further events.

Regards.


Show quoteHide quote
"Pete Smith" <PeteSmit***@hotmail.com> escribió en el mensaje
news:umifBXeJGHA.424@TK2MSFTNGP12.phx.gbl...
| Which is the appropriate one to use in the above choice?
| VB.Net. .Net Framework 1.1
| Thank you,
| Pete