Home All Groups Group Topic Archive Search About

Ending an app programmatically

Author
14 Jun 2006 1:40 PM
Schemer
Hello,

I have a C# test app that I want to terminate after it has executed the
functions being tested.
Where is the best place to do this, and how?

static void Main()
{
    Application.Run(new Form1());
}

Once the Form1 constructor returns, the app is running in the message loop.
Adding Application.Exit() to the constructor doesn't seem to work, either.
Is there a way to send a message like WM_QUIT to the app, from the form's
constructor?
TIA.

Author
14 Jun 2006 2:07 PM
CT
static void Main()
{
            Form1 form1 = new Form1();
            form1.Show();
}


--
Carsten Thomsen
Communities - http://community.integratedsolutions.dk
---------
Voodoo Programming: Things programmers do that they know shouldn't work but
they try anyway, and which sometimes actually work, such as recompiling
everything. (Karl Lehenbauer)
---------
Show quote
"Schemer" <jumper@nospam.nospam> wrote in message
news:uI%23qZg7jGHA.4716@TK2MSFTNGP03.phx.gbl...
> Hello,
>
> I have a C# test app that I want to terminate after it has executed the
> functions being tested.
> Where is the best place to do this, and how?
>
> static void Main()
> {
>    Application.Run(new Form1());
> }
>
> Once the Form1 constructor returns, the app is running in the message
> loop.
> Adding Application.Exit() to the constructor doesn't seem to work, either.
> Is there a way to send a message like WM_QUIT to the app, from the form's
> constructor?
> TIA.
>
>
>
>
Author
14 Jun 2006 2:21 PM
Schemer
> static void Main()
> {
>            Form1 form1 = new Form1();
>            form1.Show();
> }

Thanks.
Author
15 Jun 2006 2:48 AM
Jeffrey Tan[MSFT]
Hi Schemer,

Thanks for your post!

For executing a test function and exit, I do not think a winform
application is required in this scenario. Creating GUI windows is a
time-consuming task which costs a lot of CPU cycles. Does a console type
application meet your need? Anyway, if your application really need the GUI
form, please feel free to go ahead. :-)

I also recommend you to take Jim Wooley's reply a look, which provides you
NUnit for testing purpose.

Thanks.

Best regards,
Jeffrey Tan
Microsoft Online Community Support
==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
Author
14 Jun 2006 7:38 PM
GhostInAK
Hello Schemer,

Bad Schemer, Bad. 

You don't want a forms application if you arent really going to use a form..

Just call yer testes from Main() and let it fall out on it's own.  No need
for a form at all.

-Boo

Show quote
> Hello,
>
> I have a C# test app that I want to terminate after it has executed
> the
> functions being tested.
> Where is the best place to do this, and how?
> static void Main()
> {
> Application.Run(new Form1());
> }
> Once the Form1 constructor returns, the app is running in the message
> loop.
> Adding Application.Exit() to the constructor doesn't seem to work,
> either.
> Is there a way to send a message like WM_QUIT to the app, from the
> form's
> constructor?
> TIA.
Author
14 Jun 2006 7:59 PM
Jim Wooley
Additionally, if this is just a test routine, why not plug it into NUnit.
That way it can be ready for regression testing when (not if) the need arises.
Jim Wooley
http://devauthority.com/blogs/jwooley/default.aspx

Show quote
> You don't want a forms application if you arent really going to use a
> form..
>
> Just call yer testes from Main() and let it fall out on it's own.  No
> need for a form at all.

>> I have a C# test app that I want to terminate after it has executed
>> the
>> functions being tested.

AddThis Social Bookmark Button