Re: How to set exit code of non-console app?
From: Chris Jobson (chris.jobson_at_btinternet.com)
Date: 09/27/04
- Next message: William Ryan eMVP: "Re: DataGrid column heading"
- Previous message: Niki Estner: "Re: Idea for a Foreach extension"
- In reply to: Peter Steele: "How to set exit code of non-console app?"
- Next in thread: Peter Steele: "Re: How to set exit code of non-console app?"
- Reply: Peter Steele: "Re: How to set exit code of non-console app?"
- Messages sorted by: [ date ] [ thread ]
Date: Mon, 27 Sep 2004 23:44:56 +0100
As I understand it the result of Main() is the application's exit code. If I
use Visual Studio to create a C# Windows Application and then modify Main()
to be:
[STAThread]
static int Main() {
Application.Run(new Form1());
return 1;
}
it seems to exit with an exit code of 1. Maybe I'm missing something because
I don't know what you mean by "Windows applications exit immediately,
leaving their windows still open." Surely if there are still windows open
then the application can't have exited (unless the windows are created by a
different thread - I don't know what happens in that case when the initial
thread exits).
Chris Jobson
"Peter Steele" <psteele@z-force.com> wrote in message
news:%23bMdlO9oEHA.1988@TK2MSFTNGP09.phx.gbl...
>I have a Windows application written in C# that I want to return a non-zero
>exit code when it it run. The problem is that as a Windows application,
>there doesn't seem to be a way to control this. The value returned by the
>Main function has no impact on the value returned by the application.
>Windows applications exit immediately, leaving their windows still open. Is
>there a way to change the value a Windows application exits with. Basically
>I want it to return 1 instead of 0. I need to do this because the
>application is launched by another application that checked for the exit
>code and this particular application expects that the program it launches
>to return a non-zero exit code.
- Next message: William Ryan eMVP: "Re: DataGrid column heading"
- Previous message: Niki Estner: "Re: Idea for a Foreach extension"
- In reply to: Peter Steele: "How to set exit code of non-console app?"
- Next in thread: Peter Steele: "Re: How to set exit code of non-console app?"
- Reply: Peter Steele: "Re: How to set exit code of non-console app?"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|