IT works with .NET 4.5 and onwards, and I believe I saw a .NET Core version, too. But here's the .NET 4.5 version: https://www.nuget.org/packages/Microsoft.Tpl.Dataflow
Install with NuGet and look to the web for examples of use. Note that many of the examples deal with async-awaitable methods, but the library works quite well with synchronous tasks as well. I had no need for async use, so my inspiration-example below is synchronous tasks only:
public void ConvertFilesInFolder(string sourceFilesFolderPath)
string filePathsAndNames = getFilePathsAndNames(sourceFilesFolderPath);
// define a new 'ActionBlock', that you can push Tasks to.
var block = new ActionBlock
}, new ExecutionDataflowBlockOptions
MaxDegreeOfParallelism = 6 // 6 simultanous conversions (limit of my 3rd-party conversion library-licence)
// Go ahead and add conversion-Tasks to the action-block:
foreach (string filePathAndName in filePathsAndNames)
block.Complete(); // that's enough jobs...
block.Completion.Wait(); // ... now go ahead and execute until they're done.
/* Note that as I set the max-degree-of-parallelism to 6, we're limited to this number of executed tasks at the same - parrallel - time. As soon as one task completes, another is retrieved from the action-block 'queque' */ }
public void ConvertAndMoveTheFile(string filePathAndName)
catch (Exception ex)
// log, but otherwise suppress and move to next.
I found this blog-post very helpful in getting introduced and started with the library.