Millkind
asked on
Pool Threading with changing parameters
emailstuff(5) is changing with the x but not changing in the threads.
Dim emailstuff() As String = {"Name", "campusbox", "recievedate", "Shippingmethod", "Trackingnumber", "Packagetype", "Noticelevel", "", "emailaddress", "originator"}
For x As Integer = 1 To 10
System.Threading.ThreadPool.QueueUserWorkItem(AddressOf sendEmail, emailstuff)
emailstuff(5) = x
Next
ASKER
I want each thread to have different parameters. Not just send the on parameter over and over. Also the sub requires an array not a string.
Change sendEmail to accept a string and just pass emailstuff(x)
this will change every time because of the array with the counter.
The other thing you can do is pass in X and reference the array globally, but I wouldn't go that route.
this will change every time because of the array with the counter.
The other thing you can do is pass in X and reference the array globally, but I wouldn't go that route.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
All the items in emailstuff will be different in each thread. I only changed the 5th one for this as a test to see how to do it. I am new to threading and the articles and tutorials were very confusing. I believe i understand what a thread pool is in theory but not in practice. Like why can't I change the input for each pass in the for loop? Im going to work with the Module now.
ASKER
With a little tweaking it works wonderfully. Also by doing the tweaking I have learned a little bit about threading. It is easier to see it done then read about it sometimes.
Thanks,
Thanks,
Open in new window