Search code examples
c#.netasynchronousasync-awaitparallel.foreachasync

Parallel.ForAsync in C# .NET?


I want to execute a for loop in C# in parallel asynchronously. But the Parallel class contains only a synchronous For method and an asynchronous ForEachAsync method (.NET 6). This looks like an oversight to me.

Where is the Parallel.ForAsync method? Is there any workaround?


Solution

  • I agree,
    not having a Parallel.ForAsync method looks like an enormous oversight. I have good news for you though: in .NET 8 and C#12 (coming out soon at 23. november 2023) this will be resolved. Parallel.ForAsync