Solved

Early Exit

Posted on 2004-08-16
1
275 Views
Last Modified: 2010-04-15
I am sure this is a simple question that I cannot find the solution to.  I have an application that within a method, it checks a property.  Based on that property I either continue with the application of need to exit the application.  I have tried Application.Exit() and ExitThread(), and each one continues on with the code after the Exit method.  I am needing to halt all code continuation because the application will crash if it does continue.  How can I immediately exit the application without crashing it?????

Thanks,
Kendal
0
Comment
Question by:gvector1
1 Comment
 
LVL 7

Accepted Solution

by:
dttri earned 500 total points
ID: 11812291
 Hello,
  You can use this code:

using System.Diagnostics;

  In an event (for example, button click) try the code below:
  Process myPro;
  myPro = Process.GetCurrentProcess();
  myPro.Kill();
  //another code, these won't execute

  Tri
0

Featured Post

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

Article by: Najam
Having new technologies does not mean they will completely replace old components.  Recently I had to create WCF that will be called by VB6 component.  Here I will describe what steps one should follow while doing so, please feel free to post any qu…
Introduction Although it is an old technology, serial ports are still being used by many hardware manufacturers. If you develop applications in C#, Microsoft .NET framework has SerialPort class to communicate with the serial ports.  I needed to…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

830 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