I am using Task classes to do multi-threaded computation.
For example:
List<Task> taskList = new List<Task>();
for(int i=0;i<10;i++){
var task = new Task(() => Console.WriteLine("Hello from taskA."));
taskList.Add(task);
task.Start();
}
Is there a way to make only, let’s say, 3 tasks to run at most, and the rest to wait?
change the MaxDegreeOfParallelism property.
example