I have a very simple for loop that looks like this
for(int i = 0; i< 26; i++)
{
DoSomething(i);
}
The DoSomething function takes about ~3 minutes to execute. I want to write a for loop that calls DoSomething() every minute without waiting for the previous call to finish. I tried to do something like this:
Parallel.For(0, 26, i =>
{
DoSomething(i);
System.Threading.Thread.Sleep(60000);
}
But it does not work since it first does the call and then sleeps. Reversing the steps also means that the DoSomething method calls fire without delay in between each call. How do I set it up so that the call to DoSomething is every minute?
Thanks!