Running a form in another thread

  • Thread starter Thread starter Nick
  • Start date Start date
N

Nick

Hi there,

I'm creating a form using the NativeWindow class to process some custom
messages. Unfortunately as it's created on the main thread of the
application it doesnt recieve messages while the thread is busy. So I'm
trying to create it on a separate thread. I can do this but the only way I
can keep the thread alive is by call Application.DoEvents. I'm not sure if
this is the correct way to do this as I'm presuming it processes all
messages to all forms in the application?

Is there any way I can create a form and keep it in a separate thread?
Thanks loads in advance.
 
Nick said:
I'm creating a form using the NativeWindow class to process some custom
messages. Unfortunately as it's created on the main thread of the
application it doesnt recieve messages while the thread is busy. So I'm
trying to create it on a separate thread. I can do this but the only way
I can keep the thread alive is by call Application.DoEvents. I'm not sure
if this is the correct way to do this as I'm presuming it processes all
messages to all forms in the application?

Your second thread needs a separate message pump. You can call
'Application.Run' on the second thread to create a message pump. However,
note that forms and controls created in different threads cannot directly
interact with each other.
 
Hi Herfried,
Your second thread needs a separate message pump. You can call
'Application.Run' on the second thread to create a message pump. However,
note that forms and controls created in different threads cannot directly
interact with each other.

Thanks for your help :-) Most appreciated.

Nick.
 

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

Similar Threads


Back
Top