S
Steven Thomas
I have an application that creates mutliple thread like this:
My code:
I have this setup to run 6 threads at a time. How can I tell when a
thread has finished?
My code:
-------------------------------------------------------------------------
Private Sub StartGPReportServer()
Try
'Dim some variables........
While IsRunning
' LOOP THROUGH THE AVAILABLE THREADS
' I HAVE AN ARRAY WITH A RECORD FOR EACH THREAD THE
APPLICATION
' CAN CREATE. IN THIS CASE 6
While c < threads
' CHECK TO SEE IF THERE ARE REPORTS TO BE RUN
If arThreadCnts(3, c) = 0 Then
'POLL THE QUEUE TO LOOK FOR WORK
dtReportToRun = cFunctions.polldb(arQueues(x),
arThreadCnts(0, c))
' IF THERE IS WORK TO BE DONE READ THE DATA
FROM THE REPORTQUEUE
If CInt(dtReportToRun.Rows.Count) > 0 Then
arThreadCnts(3, c) = 1
'CInt(arThreadCnts(3,c)) + 1
'READ THE DATA ABOUT THE REQUEST
Dim cAccessFunc as new clsAccessFunctions
Dim othread1 As New Thread(AddressOf
cAccessFunc.CAccessSnapShot)
'Create the new thread
'SET THE PROPERTIES OF THE SUB
othread1.Name = CStr(arThreadCnts(1,
c))
cAccessFunc.pQConnectionString =
arQueues(x)
cAccessFunc.pInputFileName =
CStr(dtReportToRun.Rows(0).Item("InputFileName"))
.........
'Start the thread
othread1.start()
End If
End If
c += 1
End While
c = 0
Thread.CurrentThread.Sleep(1000)
End While
Catch errorVariable As Exception
'Error trapping
cFunctions.WriteEventLog("GPReport Could not start : " &
CStr(System.DateTime.Now()) & " " & errorVariable.Message.ToString)
End Try
End Sub
I have this setup to run 6 threads at a time. How can I tell when a
thread has finished?