I've got an application where I need to open many forms which are heterogeneous to my own and run independently. My application then proceeds to block on long running operations (making those operations asynchronous is not possible). So I would like to run these forms on a separate thread with their own message pump. Any way to do that?
+2
A:
Application.Run();
This should launch the form on its own thread, with its own message pump.
Since a new UI thread is created whenever Application.Run is invoked, this should accomplish what you are looking for.
EDIT #2: http://msdn.microsoft.com/en-us/library/system.windows.forms.application.run(VS.71).aspx
The documentation is a little ambiguous. I've always accomplished long running operations by using a ThreadPool and periodically marshalling control back to the form to render status, but it sounds like you could spawn multiple forms with Application.Run().
Tim
2010-10-07 04:53:13
...standing by...
Alastair Pitts
2010-10-07 04:54:30
@Alastair - +1 LOL
Tim
2010-10-07 04:56:38
@Tim: Nice detective work! +1 :)
Alastair Pitts
2010-10-07 05:32:09
The answer could be more precise - Create a separate thread. In it's worker function, use `Application.Run(Form)`. I hope I interpreted it right. :)
Nayan
2010-10-07 05:40:42
@Nayan - +1 That's how I read it too, but I can't speak precisely on this one so I would rather link to the documentation than provide the WRONG answer.
Tim
2010-10-07 05:49:12
Yeah... documentation.. tell me about it. Sigh!
Nayan
2010-10-07 06:01:49