Creating and displaying windows form in thread

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

walter leinert

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
 
S

Shawn Burke [MS]

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

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top