modeless form from a multithreaded application

  • Thread starter Thread starter Richard Bell
  • Start date Start date
R

Richard Bell

I'm new to VB.net and have a multithreaded application that needs to
display a VB form with a cancel button. The thread that displays the
form needs to set a cancel flag if the button is pressed. It also
needs to look for a thread event that signals that other threads have
completed work. I'm a bit unsure of how to approach this problem.

If I show the form

fProgress.Show()

it only partially displays (the cancle button is a 'hole') and it is
not active.

I'd appreciate any clues or examples.

Thanks
 
I'm new to VB.net and have a multithreaded application that needs to
display a VB form with a cancel button. The thread that displays the
form needs to set a cancel flag if the button is pressed. It also
needs to look for a thread event that signals that other threads have
completed work. I'm a bit unsure of how to approach this problem.

If I show the form

fProgress.Show()

it only partially displays (the cancle button is a 'hole') and it is
not active.

I'd appreciate any clues or examples.

Thanks

Richard...

Use fProgress.ShowDialog() or on this thread call Application.Run to
start a message loop...

Dim t As New Thread(AddressOf ThreadProc)
t.Start
....


Private Sub ThreadProc()
Dim fProgress As New ProgressForm()

Application.Run(fProgress)
End Sub
 
Thanks Tom.

My understanding is that ShowDialog() is blocking, in which case my
thread does not continue to run. Is that the case? If so, when my
cancel button is clicked, how do I exit the form so that a ShowDialog
returns to its invoking thread?

If I start a new thread do I have to worry about subsequently doing an
application.exit? I'm a bit unclear on the notion of forms and what
thread/environment they execute in. In particular the workings of
application.run and exit are not clear.

Thanks again for your help.
 
Back
Top