In one of my multi threading programs I cannot get my threads to abort. I have about 5 threads and the threads starts one at a time. By the time the fifth thread is started the program gets really slow. The program will not execute pass LoadWheelStn1. How should I resolve this problem?
I am using vb 2005Code:Private Sub LoadWheelStn1() If sPortOpenFlag = "T" Then Dim MyThread1 As New Thread(AddressOf ThreadStn1) MyThread1.Start() End If End Sub Private Sub ThreadStn1() Dim varRcvBuff1 As Integer Try Thread.Sleep(3000) Application.DoEvents() SyncLock Me varRcvBuff1 = AxAComm1.get_ValueD(900) 'do stuff End SyncLock Do While (varRcvBuff1 <> 25) Thread.Sleep(331) Application.DoEvents() SyncLock Me varRcvBuff1 = AxAComm1.get_ValueD(900) 'do stuff End SyncLock Loop If (varRcvBuff1 = 25) Then varRcvBuff1 = 0 LoadWheelStn1() If Thread.CurrentThread.IsAlive Then Thread.CurrentThread.Abort() End If End If Catch ex As Exception Select Case Err.Number Case 0 Case Else End Select Finally Thread.CurrentThread.Abort() End Try End Sub




Reply With Quote