Viper,
I assume that you run your application using the first form. i.e. your Main
routine is something like:
[STAThread]
static void Main()
{
Application.Run(new FirstForm());
}
Take a look at Application.Run on MSDN library. The overload used above
allows you to specify the main form, and the application installs a Close
event handler on this form which calls the ExitThread method on the
application to close the app.
As an alternative, you can create the form yourself in the Main() routine,
then show the form modelessly using FirstForm.Show(), and then call
Application.Run(). Then your app will keep running until one of the forms
calls Application.ExitThread(). eg:
[STAThread]
static void Main()
{
FirstForm ff = new FirstForm();
ff.Show();
Application.Run();
}
Dont forget to call Application.ExitThread() anywhere where the last visible
form closes, otherwise your application will stay alive with no UI visible.
HTH,
Chris.
"Viper" wrote:
.... say, like MS Word opens another instance of himself when you open
another document.
If you close the first 'Word', the second document remains alive. I can't
figure out how to do the same with
mySecondForm.Show();
myFirstForm.Close(); // also closes mySecondForm too
Thanks.
A lot.