Windows Forms / UI unresponsive

  • Thread starter Thread starter cbrown
  • Start date Start date
C

cbrown

I have a vb app that watches the COM port for incoming data. When it
sees that data it, it displays a form with a single label control on
it. When I call the form.Show() method, the form shows up, but the
label control does not draw and is transparent. Only if I do not open
the COM port does the label control draw (which of course defeats the
purpose). I am assuming I have to jump into multi-threading to correct
this, but my attempts so far have not got me anywhere. I have tried
watching the COM port on its own thread, which doesn't work
altogether, and I have tried displaying the Form on its own thread, but
it just opens the form and then immediately closes itself.
 
I have a vb app that watches the COM port for incoming data. When it
sees that data it, it displays a form with a single label control on
it. When I call the form.Show() method, the form shows up, but the
label control does not draw and is transparent. Only if I do not open
the COM port does the label control draw (which of course defeats the
purpose). I am assuming I have to jump into multi-threading to correct
this, but my attempts so far have not got me anywhere. I have tried
watching the COM port on its own thread, which doesn't work
altogether, and I have tried displaying the Form on its own thread, but
it just opens the form and then immediately closes itself.

You should do your com port stuff in a seperate thread. From what I've
read in this form it is bad practice to do ui stuff outside of the main
thread. It should work but make sure you do the watching and the
reading from the port in the same new thread. If you still have issues,
post some code.

Chri
 
CBrown,

If it is not in VB2005 which has the backgroundworkerclass for this, than
you can do it in the technical correct way using multithreading (my problem
is that it destroys the logic of your program) or in a technical less
correct however giving very good descripting syntax giving way using the
Applications.DoEvents in a loop. In that loop you should have than the
Threading.thread.Wait(milliseconds), to avoid that your program is completly
bound to that loop.

I hope this helps,

Cor
 
Thanks Cor,
I coded in the Application.DoEvents() with the form and it loads up
correctly. I will need to add multithreading for the other pop-ups
since they require user input.
 

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

Back
Top