Is there any way possible in a windows application project to kill the default current thread of the project and run a new thread and then relate the project to it?
My case scenario:-
I have a startup form. In its Load event I want to kill the current thread, create a new thread and run the project through the new thread. This'll be applicable in closing the startup form and open another form. When I run, the new thread is being created, everything is ok. But as soon as the default/current thread is being killed the application is closing down. How can I tackle this? Provided, I don't want to hide the startup form or stuffs like that.
Plz help. Regards.

1 answers
You might be able to join the new thread with the default one.
http://msdn.microsoft.com/en-us/library/95hbf2ta.aspx
Once you call join from the default thread, that thread will block until the new thread exits. The old thread will still exist, of course, but will be essentially frozen.
Of course, you can always just call Close() on your startup form to unload it from memory instead.
answered 2 years ago by:
60
If you're basically wanting to close down the startup form without closing down the whole application, then you can do this without starting a new thread.
If in your Main() method, you replace this line (or similar):
Application.Run(new Form1());
with these lines:
new Form1().Show();
Application.Run();
then the application will no longer close when the startup form is closed.
However, you'll need to call Application.Exit() from your second form's FormClosed eventhandler because the application won't close automatically when the second form closes even if there are no other open forms. If you forget to do this, then you'll have to kill the windowless process from the Task Manager.
answered 2 years ago by:
17279
This post was imported from csharpfriends, if you have a similiar question please ask it again.
All previous members have been migrated, hope you enjoy the new platform!