My applications supposed to create many threads and after several minutes, the CPU management is 100% busy. What's the problem?? May be that the threads are open?? can i dispose then??
This is the code that generates the CPU problem.
Private Sub tiHour_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tiHour.Tick
Dim CurThreadStart As ThreadStart
Dim ThreadCount As Integer
Dim i As Integer
If Not Listener.Pending() Then
Exit Sub
End If
tiHour.Enabled = False
CurThreadStart = New ThreadStart(AddressOf ProcessRequest)
CurThread = New Thread(CurThreadStart)
CurThread.Start()
tiHour.Enabled = true
End Sub
In ProcessRequest
CurThread = System.Threading.Thread.CurrentThread()
Application.DoEvents()
SyncLock CurThread
Try
Call sProcess(ActiveThreads)
Catch ex As Exception
Finally
End Try
End SyncLock
This is the code that generates the CPU problem.
Private Sub tiHour_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tiHour.Tick
Dim CurThreadStart As ThreadStart
Dim ThreadCount As Integer
Dim i As Integer
If Not Listener.Pending() Then
Exit Sub
End If
tiHour.Enabled = False
CurThreadStart = New ThreadStart(AddressOf ProcessRequest)
CurThread = New Thread(CurThreadStart)
CurThread.Start()
tiHour.Enabled = true
End Sub
In ProcessRequest
CurThread = System.Threading.Thread.CurrentThread()
Application.DoEvents()
SyncLock CurThread
Try
Call sProcess(ActiveThreads)
Catch ex As Exception
Finally
End Try
End SyncLock