How do I add a finalizer that runs once all parallels have completed?
Parallel.ForEach(entries, new ParallelOptions { MaxDegreeOfParallelism = 15 }, async (entry) =>
// Do something with the entry.
});
I have tried like this but it doesn't compile:
Parallel.ForEach(entries, new ParallelOptions { MaxDegreeOfParallelism = 15 }, async (entry) =>
// Do something with the entry.
}, () => { // Was hoping this would work. });
See Question&Answers more detail:os