Reputation: 612
using .NET 3.5. I have a function I want to make multithreaded calls to. The user currently sets the max number of threads in the application and I spin them up in a for loop with new Thread(Run).Start(). The Run function is in a while loop and runs until a class level boolean is set to false.
What I want to be able to do is allow the user to change the maxThread value while the application is running it's back end processes and have the application adjust the amount of threads running. Is there some kind of thread manager in .NET 3.5 I can use or will this be a roll my own situation. If it's a roll my own I would appreciate any seed ideas you might have on what the best way of accomplishing this would be.
Upvotes: 1
Views: 3812
Reputation: 48949
Is there some kind of thread manager in .NET 3.5
Yes, you can use the Reactive Extensions backport of the Task Parallel Library for .NET 3.5.
I would not worrry about controlling the maximum number of threads dynamically. The TPL is suppose to handle all of that for you.
Upvotes: 1
Reputation: 4083
Look up ThreadPool's
but it will depend on how you are getting your maxthread value.
Upvotes: 1
Reputation: 39248
I think an easy custom solution would be to control the maxThread value from a database table. There are also other more lightweight approaches like writing the value to a text file/config file etc.
Good luck
Upvotes: 1