473,325 Members | 2,816 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,325 software developers and data experts.

Form.Show error within a Thread

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
2 1110
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
"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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: me | last post by:
I have a Class Library that contains a Form and several helper classes. A thread gets created that performs processing of data behind the scenes and the Form never gets displayed (it is for debug...
1
by: MSDousti | last post by:
Hi all, I have written a program, which uses some threads. I call thread t from the main thread, and then after some work t must show a modal window.(e.g. a messagebox) but because t is not the...
3
by: aprivate | last post by:
Hi I am having some problem with a form timer. I added a progress bar to increment its value and the timer works when I use form1.showdialog() However when I use form1.show, form1.refresh()...
6
by: pamelafluente | last post by:
Hi guys I am puzzed (???) with a probably stupid problem (VB2003). I must be doing something dumb ... I want to open a owned form (must *not* be mdi child) over an Mdi Container, when the Mdi...
5
by: Jerry Spence1 | last post by:
I have the following which generates MDI forms, but doesn't show them at this stage: For n As Integer = 1 To 10 fmViewer(n) = New frmViewer fmViewer(n).Tag = n fmViewer(n).MdiParent =...
5
by: Miro | last post by:
I will try my best to ask this question correctly. I think in the end the code will make more sence of what I am trying to accomplish. I am just not sure of what to search for on the net. I...
22
by: Zytan | last post by:
I have public methods in a form. The main form calls them, to update that form's display. This form is like a real-time view of data that is changing. But, the form may not exist (it is...
9
by: RvGrah | last post by:
I'm completely new to using background threading, though I have downloaded and run through several samples and understood how they worked. My question is: I have an app whose primary form...
1
by: Franck | last post by:
I have a form with a loading bar as marquee so i don't need to play with the progress thing. It's just a form to show activity in other way. So what i need to do is start it at the beginning of...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.