Create new form from alternate thread

  • Thread starter Thread starter xmutantduck
  • Start date Start date
X

xmutantduck

Hi, I am trying to write a program that can spawn forms when running in
an alternate thread outside the main one. It however doesnt like to do
anything related to the first thread when in the second one. How can i
create a secondary form from an alternate thread? Thanks.
 
xmutantduck said:
Hi, I am trying to write a program that can spawn forms when running in
an alternate thread outside the main one. It however doesnt like to do
anything related to the first thread when in the second one. How can i
create a secondary form from an alternate thread?


I am courious why you would want to create the forms on separate threads.
Instead of running forms in separate threads I suggest to put the operations
the forms are performing into separate threads and keep all of the forms
running in the application's main thread.
 
If you want the alternate thread initiating the display of other forms
then you need to use Control.Invoke to marshal a method onto the main
UI thread where you can safely display other forms.

Brian
 
Thanks. I will look more deeply into what you said brian.

The reason I am trying to initiate forms from an alternate thread is
because I have a thread running as a listner, and when it detects an
incomming packet, it displays a chat window. I have attempted putting
it all in its own class(s) and using events, but it was being... cool.
So basically, there WAS no way for me to have the main thread initiate
the form.
 
I also needed the forms to be able to send and receive messages while
open, so OpenDialog wouldnt cut it.
 

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