Creating and displaying windows form in thread

  • Thread starter Thread starter cube
  • Start date Start date
C

cube

Hi

I've got a problem. I try to create new WindowsForm in thread and show them.
Everything is ok, but new form after Show() freeze :(

Maybe somebody tell me why and how to fix this error.
 
Hi,

you know, there some restrictions when using multithreading in a windows
forms application; i think only the thread which created a control may call
methods of this control; any other thread may only call the methods Invoke,
BeginInvoke, and EndInvoke which are marshalled to the control-owning
thread. You can test the a thread if these asycnronous calls are required by
testing the control property InvokeRequired.

I hope this helps,

Walter
 
You need to start a message pump on the thread...Windows pumps the first few
messages for you, which is what shows the window.

private void ThreadProc() {
Form f = new Form();
Application.Run(f);
}
 
Back
Top