I'm trying to make a C# tool where the user can choose how many threads he want for the tool to execute at the same time. So for example he put "10" in the threadsTextBox so when he will click the startButton the program will start and will execute the needed task on 10 threads at the same time.
Here is the current code I have for 3 threads, but I don't know how to make the user able to choose how many threads he want the program to use.
static void Main(string[] args)
{
Task task1 = Task.Factory.StartNew(() => doStuff());
Task task2 = Task.Factory.StartNew(() => doStuff());
Task task3 = Task.Factory.StartNew(() => doStuff());
Task.WaitAll(task1, task2, task3);
Console.WriteLine("Done !");
}
static void doStuff()
{
// do stuff here
}
Thanks in advance.