CPU problem

Celeris

New member
Joined
Jul 13, 2005
Messages
2
Programming Experience
3-5
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

 
Thanks but it is not the solution because my timer generates the threads when a comunication arrives by tcp/ip, and into the thread i generate a socket to work with the message´s value.

Private Listener As TcpListener
Public CurThread As Thread

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

Any ideas??

Thanks a lot
 
Back
Top