Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / New Users / June 2006

Tip: Looking for answers? Try searching our database.

Ending an app programmatically

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Schemer - 14 Jun 2006 14:40 GMT
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.
CT - 14 Jun 2006 15:07 GMT
static void Main()
{
           Form1 form1 = new Form1();
           form1.Show();
}

Signature

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)
---------

> Hello,
>
[quoted text clipped - 13 lines]
> constructor?
> TIA.
Schemer - 14 Jun 2006 15:21 GMT
> static void Main()
> {
>            Form1 form1 = new Form1();
>            form1.Show();
> }

Thanks.
"Jeffrey Tan[MSFT]" - 15 Jun 2006 03:48 GMT
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.
GhostInAK - 14 Jun 2006 20:38 GMT
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

> Hello,
>
[quoted text clipped - 14 lines]
> constructor?
> TIA.
Jim Wooley - 14 Jun 2006 20:59 GMT
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

> 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.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.