Solved

Application Exit? End? Quit? How to?? C#

Posted on 2009-04-08
4
829 Views
Last Modified: 2012-05-06
Application: C# Multiform Windows Application

I have an app that I will have a button for "Logout" that will run a series of code, and then is supposed to end the program. What code can I use that quickly terminates the application?

In Visual Basic I used:

End


Thanks.
0
Comment
Question by:ProWebNetworks
  • 2
  • 2
4 Comments
 

Expert Comment

by:jeremymjackson
ID: 24098552
application.close()
0
 
LVL 1

Author Comment

by:ProWebNetworks
ID: 24098605
Application.Close() gives error:
System.Windows.Forms.Application does not contain a definition for 'close'



I was thinking maybe:
System.Environment.Exit(0);




---I am going to test this now.
0
 
LVL 1

Accepted Solution

by:
ProWebNetworks earned 0 total points
ID: 24098627
System.Environment.Exit(0);



This snippet seems to do the job.
0
 

Expert Comment

by:jeremymjackson
ID: 24098752
Application.Exit(); is the correct syntax.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

In order to hide the "ugly" records selectors (triangles) in the rowheaders, here are some suggestions. Microsoft doesn't have a direct method/property to do it. You can only hide the rowheader column. First solution, the easy way The first sol…
This article introduced a TextBox that supports transparent background.   Introduction TextBox is the most widely used control component in GUI design. Most GUI controls do not support transparent background and more or less do not have the…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
A company’s greatest vulnerability is their email. CEO fraud, ransomware and spear phishing attacks are the no1 threat to a company’s security. Cybercrime is responsible for the largest loss of money to companies today with losses projected to r…

914 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now