1

I wrote a simple console application that should process some tasks in parallel. For this I used Parallel.ForEachlike this:

        Parallel.ForEach(_jobs, async job =>
        {
            await job.DoItAsync();
        });
        Console.Read();

My application should stop when all tasks in the list _jobs have finished. However, this works only if I have a "Console.Read()" after the Parallel. Now the user has to enter a key after the processing has ended. But this is not what I want. I want the app to close automatically after my execution has finished.
But if I remove the Read() statement, my app just exists directly without doing anything.

Any ideas what I need to change here?

Theodor Zoulias
  • 24,585
  • 5
  • 40
  • 69
David Mason
  • 455
  • 3
  • 10

0 Answers0