I have an application that creates mutliple thread like this:
My code:[color=blue]
> -------------------------------------------------------------------------
> Private Sub StartGPReportSe rver()
> 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.poll db(arQueues(x),
> arThreadCnts(0, c))
> ' IF THERE IS WORK TO BE DONE READ THE DATA
> FROM THE REPORTQUEUE
> If CInt(dtReportTo Run.Rows.Count) > 0 Then
> arThreadCnts(3, c) = 1
> 'CInt(arThreadC nts(3,c)) + 1
> 'READ THE DATA ABOUT THE REQUEST
> Dim cAccessFunc as new clsAccessFuncti ons
> Dim othread1 As New Thread(AddressO f
> cAccessFunc.CAc cessSnapShot)
>
> 'Create the new thread
> 'SET THE PROPERTIES OF THE SUB
> othread1.Name = CStr(arThreadCn ts(1,
> c))
> cAccessFunc.pQC onnectionString =
> arQueues(x)
> cAccessFunc.pIn putFileName =
> CStr(dtReportTo Run.Rows(0).Ite m("InputFileNam e"))
> .........
> 'Start the thread
> othread1.start( )
> End If
> End If
> c += 1
> End While
> c = 0
> Thread.CurrentT hread.Sleep(100 0)
> End While
> Catch errorVariable As Exception
> 'Error trapping
> cFunctions.Writ eEventLog("GPRe port Could not start : " &
> CStr(System.Dat eTime.Now()) & " " & errorVariable.M essage.ToString )
> End Try
> End Sub[/color]
I have this setup to run 6 threads at a time. How can I tell when a
thread has finished?
My code:[color=blue]
> -------------------------------------------------------------------------
> Private Sub StartGPReportSe rver()
> 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.poll db(arQueues(x),
> arThreadCnts(0, c))
> ' IF THERE IS WORK TO BE DONE READ THE DATA
> FROM THE REPORTQUEUE
> If CInt(dtReportTo Run.Rows.Count) > 0 Then
> arThreadCnts(3, c) = 1
> 'CInt(arThreadC nts(3,c)) + 1
> 'READ THE DATA ABOUT THE REQUEST
> Dim cAccessFunc as new clsAccessFuncti ons
> Dim othread1 As New Thread(AddressO f
> cAccessFunc.CAc cessSnapShot)
>
> 'Create the new thread
> 'SET THE PROPERTIES OF THE SUB
> othread1.Name = CStr(arThreadCn ts(1,
> c))
> cAccessFunc.pQC onnectionString =
> arQueues(x)
> cAccessFunc.pIn putFileName =
> CStr(dtReportTo Run.Rows(0).Ite m("InputFileNam e"))
> .........
> 'Start the thread
> othread1.start( )
> End If
> End If
> c += 1
> End While
> c = 0
> Thread.CurrentT hread.Sleep(100 0)
> End While
> Catch errorVariable As Exception
> 'Error trapping
> cFunctions.Writ eEventLog("GPRe port Could not start : " &
> CStr(System.Dat eTime.Now()) & " " & errorVariable.M essage.ToString )
> End Try
> End Sub[/color]
I have this setup to run 6 threads at a time. How can I tell when a
thread has finished?
Comment