๐ Utilities to aid in utilizing the ever-useful .NET structure BlockingCollection<T>
Find it on nuget!
PM> Install-Package BlockingCollectionExtensions -Version 6.0.1
/// <summary>
/// Transfer contents of a generic enumerable into a target blocking collection,
/// determine whether blocking collection should complete adding when enumerable has finished being added
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="target"></param>
/// <param name="source"></param>
/// <param name="completeAddingWhenDone"></param>
public static void AddFromEnumerable<T>(this BlockingCollection<T> target, IEnumerable<T> source,
bool completeAddingWhenDone);
/// <summary>
/// Coalesce a target blocking collection to a structure that implements the IProducerConsumerCollection interface
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="collection"></param>
/// <param name="millisecondsTimeout"></param>
/// <param name="cancellationToken"></param>
/// <param name="count"></param>
/// <param name="isSynchronized"></param>
/// <param name="syncRoot"></param>
/// <returns></returns>
public static IProducerConsumerCollection<T> ToProducerConsumerCollection<T>(
this BlockingCollection<T> collection, int millisecondsTimeout, CancellationToken cancellationToken,
int count, bool isSynchronized, object syncRoot);