Question Thread problem!!Help me

memo421

New member
Joined
Dec 6, 2008
Messages
2
Programming Experience
Beginner
I have code like below:

Private Sub btnConnect_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnConnect.Click
Try
DO something

Dim th1 As New Thread(AddressOf ThreadStart)
th1.IsBackground = True
'End If
th1.Start()


Catch ex As Exception
DO something
End Try

End Sub
When I click Button, as thread starts by th1.start, it starts thread without ending btnConnect_Click.
It starts thread, executes few statements of "ThreadStart" and then come back to btnConnect_Click and ends it then again move to thread "ThreadStart" , execute few statement and terminate without any prompt/error.

Can anyone help me.

Thanks.
 
How exactly are you determining this? Are you using a breakpoint? If so then you're probably breaking all threads, which is the default behaviour. Use Console.WriteLine to output messages to the Output window to see how the threads behave as far as timing is concerned.

If you want to change the IDE behaviour so that breaking on one thread doesn't stop any other threads then you can do so through the Options dialogue. I'm not going to tell you where that specific option is because I don't know off hand and it will be beneficial for you to look for yourself. Everyone should have a thorough look through the IDE options.
 
Back
Top