M
Max
Playing around with multi-threading programs and ran into this little
problem that maybe someone here could explain... Basically I have a
class which launches a form object. Once the form is launched (using
ShowDialog) I still needed both to be available, so my solution was to
start the form in a new thread. This way the program itself can still
use the class and the user can interact with the form. So here's how I
did this:
Public Sub OpenForm()
GUIThread = New Thread(GUIThreadStart)
GUIThread.Start()
Thread.CurrentThread.Sleep(1000)
End Sub
Private Sub MyThread()
MyForm.ShowDialog()
End Sub
I didn't put in all the definitions, but basically MyThread() is the
starting point for the GUIThread. The problem comes in where you see
that Sleep(1000) line. If I don't put that line in the form opens up
completely unresponsive and essentially looks frozen. Why does that
happen? I thought as soon as I start the new thread it just goes along
its own road. Why do I need to pause the execution of the main thread in
order to have the form be able to show?
problem that maybe someone here could explain... Basically I have a
class which launches a form object. Once the form is launched (using
ShowDialog) I still needed both to be available, so my solution was to
start the form in a new thread. This way the program itself can still
use the class and the user can interact with the form. So here's how I
did this:
Public Sub OpenForm()
GUIThread = New Thread(GUIThreadStart)
GUIThread.Start()
Thread.CurrentThread.Sleep(1000)
End Sub
Private Sub MyThread()
MyForm.ShowDialog()
End Sub
I didn't put in all the definitions, but basically MyThread() is the
starting point for the GUIThread. The problem comes in where you see
that Sleep(1000) line. If I don't put that line in the form opens up
completely unresponsive and essentially looks frozen. Why does that
happen? I thought as soon as I start the new thread it just goes along
its own road. Why do I need to pause the execution of the main thread in
order to have the form be able to show?