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
  • 34,835
  • 7
  • 69
  • 104
David Mason
  • 915
  • 1
  • 9
  • 27

0 Answers0