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 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…