Halting and Debugging thread?

G

Guest

I have three data processing routines which I want to run in threads so that
they don’t clog up the UI. How can I halt execution of thread until prior
thread completes successfully.

Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button3.Click

'Link tables.
'Spin off a new thread.
t1 = New Thread(New ThreadStart(AddressOf CreateLinks))
t1.IsBackground = True
t1.Start()

Select Case True

Case optRawFigures.Checked
'Spin off a new thread.
t2 = New Thread(New ThreadStart(AddressOf GetFigures))
t2.IsBackground = True
t2.Start()

Case optAverage.Checked
'Spin off a new thread.
t3 = New Thread(New ThreadStart(AddressOf CalculateFigures))
t3.IsBackground = True
t3.Start()

End Select

End Sub

Apparently thread t1 is executed on button click along with one of the
threads from Select Case. This leads to error because tables need to be
linked before any data processing job can be done.

I want t1 to execute and when it is completed successfully it should execute
Select Case.

Also, how can I debug the routine which runs off a thread.

Thanks
 
J

Jon Skeet [C# MVP]

Job Lot said:
I have three data processing routines which I want to run in threads so that
they don?t clog up the UI. How can I halt execution of thread until prior
thread completes successfully.

I would suggest that you only have one extra thread, and that does both
the table linking and then whichever of the other options is the one
you want.

As for debugging - you debug just as you would anything else, by
putting breakpoints in, stepping through etc.
 

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

Top