Skip to content

Instantly share code, notes, and snippets.

View poulfoged's full-sized avatar

Poul Foged Nielsen poulfoged

View GitHub Profile
internal static class AsyncHelper
{
public static Task ForEachAsync<T>(this IEnumerable<T> source, int dop, Func<T, Task> body)
{
return Task.WhenAll(
Partitioner.Create(source)
.GetPartitions(dop)
.Select(partition => Task.Run(async delegate
{
using (partition)
using System;
using System.IO;
using System.Linq;
using System.Threading;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System.Net.Http;
using System.Collections.Generic;
using System.Net;
using System.Threading.Tasks;
using System.Text;