Create forms from threads

  • Thread starter Thread starter Kevin Chabot
  • Start date Start date
K

Kevin Chabot

Hi,

I need to be able to create one or more form(s) from a method that is
called from different threads. When this form is created, it appears but
it does not receive any message. It looks blank, and when you move your
cursor over it, it becomes an hourglass.

Can anyone help me with this?
Thanx in advance...

Kind regards,
Kevin Chabot
 
Kevin,

What you will want to do is call the Invoke method on a control that is
hosted on the main UI thread. This method will take a delegate and an array
of objects (the parameters) and call the target of that delegate in the main
UI thread. You would create a delegate which would point to a method which
creates and shows the form.

You could also run a new message loop through a call to the static Run
method on the Application class in the new thread, but I would advise
against that (it's not common practice, and I don't think the Run method was
meant to be called more than once).

Hope this helps.
 
Back
Top