private static async Task RunProducer(IProducer <TP> parallelProducer, IProducerBuffer <TP> feed, CancellationToken token, CancellationTokenSource tokenSrc) { try { #if NETFRAMEWORK || NETSTANDARD2_0 using (parallelProducer) #else await using (parallelProducer.ConfigureAwait(false)) #endif { await parallelProducer.InitAsync().StartIfNeeded().ConfigureAwait(false); token.ThrowIfCancellationRequested(); await parallelProducer.ProduceAsync(feed, token).StartIfNeeded().ConfigureAwait(false); } } catch { if (!token.IsCancellationRequested) { tokenSrc.Cancel(); } throw; } }