Is it possible to do the following using the new Async/Await features in c#:
static void Main(string[] args)
{
Thread[] thread = new Thread[101];
for (int i = 0; i < 101; i++)
{
thread[i] = new Thread(IntenseWork);
thread[i].Start();
}
Finish(thread);
}
private static void IntenseWork()
{
Thread.Sleep(5000);
}
private static void Finish(Thread[] threadArray)
{
foreach (Thread ta in threadArray)
{
ta.Join();
}
Console.WriteLine("Press Any Key to Continue...");
Console.ReadKey();
}
I am aware there are limitations of Async/Await that you can only do using thread. But for an example like this where there is one function DoWork that needs to be ran on several threads at the same time, can it be done?