473,897 Members | 2,557 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Properly Exiting an application

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.Exi t it closes the form and ends the application but the
NotifyIcon doesn't remove itself unless you hover a mouse cursor over it.

I guess my question is, am I gaining anything by using the Application.Exi t
command rather than using the Me.Close command?

Just a noob wondering.

Thanks
John
Nov 20 '05 #1
3 1881
"John Wildes" <sp******@kisso ff.com> schrieb
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.Exi t it closes the form and ends
the application but the NotifyIcon doesn't remove itself unless you
hover a mouse cursor over it.

I guess my question is, am I gaining anything by using the
Application.Exi t command rather than using the Me.Close command?

Just a noob wondering.


Application.Exi t kills the application right away and events usually
expected when Forms are closed are not raised. The remaining NotifyIcon is a
visible example that resources are not cleaned up very well.

--
Armin

http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html

Nov 20 '05 #2
* "John Wildes" <sp******@kisso ff.com> scripsit:
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.Exi t it closes the form and ends the application but the
NotifyIcon doesn't remove itself unless you hover a mouse cursor over
it.
Have a look at the documentation for 'Application.Ex it', there you will
learn what 'Exit' does and what 'Exit' doesn't do.
I guess my question is, am I gaining anything by using the Application.Exi t
command rather than using the Me.Close command?


It's better to close the forms by calling their 'Close' method and
removing the icon "by hand" (thorugh your own code).

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
Nov 20 '05 #3
This situation is analogus to the VB 6.0 "unload Me" vs. "End" where
me.close equates to unload Me and Application.Exi t equates to End.

Application.Exi t does what it says, it kills the application right then and
there. The form's normal event sequence is abruptly cut off and the form
doesn't get a chance to fully terminate itself as it would if you call
Me.Close.
"John Wildes" <sp******@kisso ff.com> wrote in message
news:%2******** ********@TK2MSF TNGP12.phx.gbl. ..
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.Exi t it closes the form and ends the application but the
NotifyIcon doesn't remove itself unless you hover a mouse cursor over it.

I guess my question is, am I gaining anything by using the Application.Exi t command rather than using the Me.Close command?

Just a noob wondering.

Thanks
John

Nov 20 '05 #4

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

Similar topics

7
4009
by: David Elliott | last post by:
I have created an application that will dynamically load other DLLs (plugins). The new plugin is a winform with an embedded IE Browser. I am wanting to have the form to run in its own thread. This would allow for other plugins and the main application to be free to do other work. I have written a little TestDriver for the plugin and am having some difficulty. If I don't use threads everything works just fine. If I do use threads, upon...
8
2604
by: Andrew Warren | last post by:
I'm trying to exit a Windows Forms application while in the form's constructor (after InitializeComponent() has been called) and am finding that calling Application.Exit () still leaves the form displayed and running. Trying to force the form to close with this.Close() does not work either. Any suggestions? Thanks.
2
1771
by: pnp | last post by:
Hi all, I'm working on a win app that uses a logon form to verify the user that logs in the program and then hides the first form and displays an MDI form where the user does his work. The app is STA. The problem is that I wan't to be able to close the app from wherever in my app (no matter how deep in the code) and make sure that all the resources are being freed after exiting the app. Any ideas? Is there a way to re-open the app...
6
3688
by: GL | last post by:
I am getting a crash while exiting from my application. Pl find the Stack Trace of the crash: System.Windows.Forms.Application.ThreadWindows.ThreadWindows(System.Windows.Forms.Control parent = <undefined value>, bool onlyWinForms = true) + 0x8c bytes system.windows.forms.dll!ThreadContext.DisposeThreadWindows() + 0x54 bytes system.windows.forms.dll!ThreadContext.Dispose() + 0xa1 bytes...
3
1520
by: Bonj | last post by:
When trying to debug an ASP.NET project by placing a breakpoint in one of the functions in the codebehind, VS correctly stops at the breakpoint, and I can step through. But soon after, the process stops dead and can't be stepped through anymore (even though there is no error) - I'm guessing that the aspnet_wp.exe is detecting that if it's inactive for a period of n seconds or so, then it exits until it gets another request. Is there...
2
10568
by: tt | last post by:
Hi, ANy ideas on this? When I click the close button of a window in VB.net which method gets called? I used Applicaton.exit in some method of my appln. to exit the application but, it still leaves the process in the process table. Can someone help me exiting an application cleanly. Thanks -tt
5
2612
by: Al | last post by:
I have an MFC based application which uses remoting using VS05. On exiting the application, I intermittently get a crash at line 195 in dllmodul.cpp (AFX_MANAGE_STATE(&afxModuleState);) The exception I see in the IDE is "Unhandled exception at 0x7c81eb33 in MgmtApp.exe: 0xC0020001: The string binding is invalid." where MgmtApp.exe is my applcation. It happens both in the client and server applications intermittently.
1
1920
by: kuhrty | last post by:
Hi, I am creating a multi-winform project. Everything has been working fine, except after I perform an update to the database and decide to Exit the winform after the update operation is complete. I have error handling in my code but not on the dispose method. I call the dispose method exiting the application using the code below but results in this error message "An unhandled exception of type 'System.NullReferenceException'
6
2525
by: Ant | last post by:
Hi all, I'm putting together a simple help module for my applications, using html files stored in the application directory somewhere. Basically it sets up a basic web server, and then uses the webbrowser module to display it in the users browser. I have it set up to call sys.exit(0) if the url quit.html is called, but for some reason (on Windows XP via the cmd.exe shell) python won't let me have the console back. I get the System Exit...
0
9990
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9837
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
11250
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9656
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
7185
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 into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5873
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4698
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
2
4293
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3300
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.