By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
428,591 Members | 650 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 428,591 IT Pros & Developers. It's quick & easy.

Form.Show error within a Thread

P: n/a
I have an application that has a thread which listens to a port for incoming
messages. The thread is declared and started in my main form, that is
opened from my sub main. In this thread, when a message has an ID in it, i
want a new form to show. I currently do this within the thread:

gContactForm = New frmContact(ID)
gContactForm.MdiParent = gMainForm.ActiveForm
gContactForm.Show()

But on the gContactForm.Show(), the form appears to 'hang' as a white
window.

Why is this happening, and more importantly, how can i fix it?
Nov 21 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Julia,

Does it work without using threading?

Cor

"Julia Chen" <He***@hellonet.com>
I have an application that has a thread which listens to a port for
incoming messages. The thread is declared and started in my main form,
that is opened from my sub main. In this thread, when a message has an ID
in it, i want a new form to show. I currently do this within the thread:

gContactForm = New frmContact(ID)
gContactForm.MdiParent = gMainForm.ActiveForm
gContactForm.Show()

But on the gContactForm.Show(), the form appears to 'hang' as a white
window.

Why is this happening, and more importantly, how can i fix it?

Nov 21 '05 #2

P: n/a
"Julia Chen" <He***@hellonet.com> schrieb:
I have an application that has a thread which listens to a port for
incoming messages. The thread is declared and started in my main form,
that is opened from my sub main. In this thread, when a message has an ID
in it, i want a new form to show. I currently do this within the thread:


Always create your forms in your application's main UI thread. Instance
members of Windows Forms forms and controls are not safe for multithreading,
so accessing them directly can cause problems. In addition to that, your
forms need a message pump which is normally provided by the app's main UI
thread.

Multithreading in Windows Forms applications
<URL:http://dotnet.mvps.org/dotnet/faqs/?id=multithreading&lang=en>

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Nov 21 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.