M
Matt
Hey guys, I'm attempting to create an event scheduler though VB.Net
2005 using threads.
The basic idea is that I can have up to 10 threads going at any given
time. Once a thread finishes I need to be able to "recycle" it so I
can use it again when necessary. Since there is no way to
"reinitialize" a thread I devised this method.
Thread1 = New System.Threading.Thread(AddressOf Task1.ExecuteShell)
If (Thread1.IsAlive = False) Then
If (ResetFlag1 = True) Then
Thread1 = Nothing
GC.Collect()
Thread1 = New System.Threading.Thread(AddressOf
Task1.ExecuteShell)
End If
Task1.EventID = "1"
Task1.TimerValue = Me.TimerBox.Text
Thread1.Start()
ResetFlag1 = True
End if
Basically what happens is that once the thread is used I set it to
Nothing, do a GC.Collect and reset the thread to a new thread. Now my
question here is will this eventually blow up because I keep creating
new instances of the thread object? Or will the garbage collection I
have implimented take care of it?
I'm not using a "threadqueue" because I need to have direct control
over the threads. Any help you could give me would be great
2005 using threads.
The basic idea is that I can have up to 10 threads going at any given
time. Once a thread finishes I need to be able to "recycle" it so I
can use it again when necessary. Since there is no way to
"reinitialize" a thread I devised this method.
Thread1 = New System.Threading.Thread(AddressOf Task1.ExecuteShell)
If (Thread1.IsAlive = False) Then
If (ResetFlag1 = True) Then
Thread1 = Nothing
GC.Collect()
Thread1 = New System.Threading.Thread(AddressOf
Task1.ExecuteShell)
End If
Task1.EventID = "1"
Task1.TimerValue = Me.TimerBox.Text
Thread1.Start()
ResetFlag1 = True
End if
Basically what happens is that once the thread is used I set it to
Nothing, do a GC.Collect and reset the thread to a new thread. Now my
question here is will this eventually blow up because I keep creating
new instances of the thread object? Or will the garbage collection I
have implimented take care of it?
I'm not using a "threadqueue" because I need to have direct control
over the threads. Any help you could give me would be great