?
Solved

Application.Exit() ... how do I send a return code upon exit.

Posted on 2006-04-03
2
Medium Priority
?
253 Views
Last Modified: 2010-04-16
I am new to C# and I want to:

Create a Windows Forms Application that will send back a return code on exit, so that another application can receive an indication that it ran sucessfully or not.

I am trying to set the exit code before I call application exit, but it does not seem to work ...

System.Environment.ExitCode = 9;
Application.Exit();

What am I missing?

PS - I am not using a Console application, because I need to invoke a form for the user to interact with.
0
Comment
Question by:mark4262
2 Comments
 
LVL 4

Accepted Solution

by:
c_myers earned 200 total points
ID: 16362903
Hrm, If I recall correctly, I think Application.Exit() shuts down the message pump in the current thread, but the application doesn't actually terminate on that line of code.

So you could probably try:

Application.Exit();
Environment.Exit(9);
0
 

Author Comment

by:mark4262
ID: 16363589
Works Perfectly! ... Thanks a bunch ...
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…
Suggested Courses

839 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