Code for Exiting a C# Application

Please support our C# advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Aug 2004
Posts: 350
Reputation: Ghost is an unknown quantity at this point 
Solved Threads: 2
Ghost's Avatar
Ghost Ghost is offline Offline
Posting Whiz

Code for Exiting a C# Application

 
0
  #1
Mar 19th, 2005
Hi,

i'm new 2 C#, so my question may seem stupid... but, what is the code to exit an application.

I know in java it is:
  1. System.exit(0);

Thanx in advanced,
C++
Last edited by C++; Mar 19th, 2005 at 3:51 am. Reason: Forgot semicolon
Reply With Quote Quick reply to this message  
Join Date: Dec 2003
Posts: 55
Reputation: r0ckbaer is an unknown quantity at this point 
Solved Threads: 6
r0ckbaer r0ckbaer is offline Offline
Junior Poster in Training

Re: Code for Exiting a C# Application

 
0
  #2
Mar 19th, 2005
Console => Environment.Exit(0)
Forms => Form.Close()
Reply With Quote Quick reply to this message  
Join Date: Jul 2004
Posts: 37
Reputation: crypter is an unknown quantity at this point 
Solved Threads: 0
crypter's Avatar
crypter crypter is offline Offline
Light Poster

Re: Code for Exiting a C# Application

 
0
  #3
Mar 19th, 2005
r0ckbear for the forms if you put Form.Close(); you will only close the form without actually exiting the application, what i put is
Application.Exit();
Reply With Quote Quick reply to this message  
Join Date: Aug 2004
Posts: 350
Reputation: Ghost is an unknown quantity at this point 
Solved Threads: 2
Ghost's Avatar
Ghost Ghost is offline Offline
Posting Whiz

Re: Code for Exiting a C# Application

 
0
  #4
Mar 19th, 2005
thank u very much
Reply With Quote Quick reply to this message  
Join Date: Dec 2003
Posts: 55
Reputation: r0ckbaer is an unknown quantity at this point 
Solved Threads: 6
r0ckbaer r0ckbaer is offline Offline
Junior Poster in Training

Re: Code for Exiting a C# Application

 
0
  #5
Mar 20th, 2005
Originally Posted by crypter
r0ckbear for the forms if you put Form.Close(); you will only close the form without actually exiting the application, what i put is
Application.Exit();
Application.Exit() is indeed the method to use when you got several forms open, but when your app consists of only one MainForm and you close it, it will exit the application as well.
Reply With Quote Quick reply to this message  
Join Date: Apr 2005
Posts: 7
Reputation: SethWebster is an unknown quantity at this point 
Solved Threads: 0
SethWebster SethWebster is offline Offline
Newbie Poster

Re: Code for Exiting a C# Application

 
0
  #6
Apr 3rd, 2005
rOckbaer,

Semantically, you are incorrect, even though in most cases that would work. What you stated will exit the Application Loop that that Application represents. For multiple Application Loops, the must all be terminated.
Reply With Quote Quick reply to this message  
Join Date: Jul 2003
Posts: 117
Reputation: Iron_Cross is an unknown quantity at this point 
Solved Threads: 2
Iron_Cross's Avatar
Iron_Cross Iron_Cross is offline Offline
Junior Poster

Re: Code for Exiting a C# Application

 
0
  #7
Apr 12th, 2005
If you're application consists of of a main form (i.e. one created by using Application.Run(new Form()); ) then closing that form exits the application. Although, if you're doing it programaticly, then I wouldn't use that.
elitehackers.info
Today's Penny-Arcade!
Pain is weakness leaving the body!
Reply With Quote Quick reply to this message  
Join Date: Jan 2008
Posts: 2,052
Reputation: serkan sendur is a glorious beacon of light serkan sendur is a glorious beacon of light serkan sendur is a glorious beacon of light serkan sendur is a glorious beacon of light serkan sendur is a glorious beacon of light serkan sendur is a glorious beacon of light 
Solved Threads: 123
Featured Poster
serkan sendur serkan sendur is offline Offline
Postaholic

Re: Code for Exiting a C# Application

 
0
  #8
Apr 20th, 2009
i cant exit the application using Application.Exit()
Due to lack of freedom of speech, i no longer post on this website.
Reply With Quote Quick reply to this message  
Join Date: Jul 2009
Posts: 1
Reputation: tunnweaung is an unknown quantity at this point 
Solved Threads: 0
tunnweaung tunnweaung is offline Offline
Newbie Poster

Re: Code for Exiting a C# Application

 
0
  #9
Jul 17th, 2009
Originally Posted by serkan sendur View Post
i cant exit the application using Application.Exit()
how abt Application.ExitThread()?
Reply With Quote Quick reply to this message  
Join Date: Oct 2009
Posts: 1
Reputation: inderneel is an unknown quantity at this point 
Solved Threads: 0
inderneel inderneel is offline Offline
Newbie Poster
 
0
  #10
Oct 23rd, 2009
Can anybody please tell how to exit from an application?
Application.Exit() and
Application.ExitThread() both are not working.

I am calling this new form from another form using
frm.ShowDialog()

Please help..
Reply With Quote Quick reply to this message  
Reply

Message:



Similar Threads
Other Threads in the C# Forum


Views: 44667 | Replies: 10
Thread Tools Search this Thread



Tag cloud for C#
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC