By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,550 Members | 908 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,550 IT Pros & Developers. It's quick & easy.

Multiple Thread Creation and Control

P: n/a
Ok so I'm creating this event scheduler in VB.NET with the use of
threads. We would like the customer to be able to declare however many
threads they want.

For example...

Lets say the user wants to be able to have 10 threads all running at
the same time. Well I would need a way to dynamically created that
number of threads at runtime and be able to control them all. Up until
now I have been statically control the thread count so I have been able
to easily control them.


'---Event Classes----------------------------
Public Task1 As New EventClass()
Public Task2 As New EventClass()
Public Task3 As New EventClass()
Public Task4 As New EventClass()
Public Task5 As New EventClass()
Public Task6 As New EventClass()
Public Task7 As New EventClass()
Public Task8 As New EventClass()
Public Task9 As New EventClass()
Public Task10 As New EventClass()
'---End Event Classes------------------------
Public Thread1 As New System.Threading.Thread(AddressOf
Public Thread2 As New System.Threading.Thread(AddressOf
Public Thread3 As New System.Threading.Thread(AddressOf
Public Thread4 As New System.Threading.Thread(AddressOf
Public Thread5 As New System.Threading.Thread(AddressOf
Public Thread6 As New System.Threading.Thread(AddressOf
Public Thread7 As New System.Threading.Thread(AddressOf
Public Thread8 As New System.Threading.Thread(AddressOf
Public Thread9 As New System.Threading.Thread(AddressOf
Public Thread10 As New System.Threading.Thread(AddressOf
'---End Threads-----------------------------

If (Thread1.IsAlive = False) Then
If (ResetFlag1 = True) Then
Thread1 = Nothing
Thread1 = New System.Threading.Thread(AddressOf
End If
Task1.EventID = "1"
ResetFlag1 = True
ElseIf (Thread2.IsAlive = False) Then
If (ResetFlag2 = True) Then
Thread2 = Nothing
Thread2 = New System.Threading.Thread(AddressOf
End If
Task2.EventID = "2"
ResetFlag2 = True
End If

As you can see I have a "queue" of 10 static threads that I see if they
are alive before assigning a job to them. And whenever I want to kill
one I just put in my "EventID", find the one I want and kill it.

I need to be able to create as many threads as I need, and control them
all. Any suggestions???

Mar 28 '06 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.