Executing multiple async methods synchronously without throwing I have a following task: execute multiple asynchronous methods synchronously and always execute them all, even when one of them throws. Rethrow thrown exceptions if any occured only after all tasks have finished. Here is my code:

public static async Task ContinueWithoutThrowing(this IEnumerable&lt;Func&lt;Task&gt;&gt; tasks)
    {
        var thrownExceptions = new List&lt;Exception&gt;();

        foreach (var task in tasks)
        {
            try
            {
                await task().ConfigureAwait(false);
            }
            catch (Exception ex)
            {
                thrownExceptions.Add(ex);
            }
        }

        if (thrownExceptions.Any())
        {
            throw new AggregateException(thrownExceptions);
        }
    }


Usage of this code is following:

Func&lt;Task&gt;[] tasks = { First, Second };
await tasks.ContinueWithoutThrowing().ConfigureAwait(false);


I am not sure whether what I am doing is accomplishable using already implemented methods on Task class like WhenAll. But using WhenAll with await throws on first exception. Also couldn't figure out some better name than ContinueWithoutThrowing when it actually throws if used with await (but its wanted behavior). I know this code doesn't handle cancellation but its not my main concern right now.
After my initial answer and based on your subsequent comments, I would say that your implementation is OK.

As for naming I would keep it simple like WhenAllCompleted

/// &lt;summary&gt;
/// Creates a task that will complete when all of the supplied tasks have completed synchronously.
/// &lt;/summary&gt;
/// &lt;param name="tasks"&gt;The tasks to wait on for completion.&lt;/param&gt;
/// &lt;returns&gt;A task that represents the completion of all of the supplied tasks.&lt;/returns&gt;
public static async Task WhenAllCompleted(this IEnumerable&lt;Func&lt;Task&gt;&gt; tasks) {
    if (tasks == null) throw new ArgumentNullException("tasks");
    var exceptions = new List&lt;Exception&gt;();
    using (var e = tasks.GetEnumerator()) {
        while (e.MoveNext()) {
            var task = e.Current;
            try {
                await task();
            } catch (Exception ex) {
                exceptions.Add(ex);
            }
        }
    }
    if (exceptions.Any()) {
        throw new AggregateException(exceptions);
    }
}


I've basically only added the null check on the provided argument. I considered doing null checks on the function and task returned like

var function = e.Current;
if (function == null) {
    exceptions.Add(new ArgumentException("The tasks collection contained a null task.", "tasks"));
    continue;
}
//...


but figured that would all be caught by your simpler implementation, so decided against it.

Though you have not added cancellation as yet the following should be of some help with an optional cancellation token

/// &lt;summary&gt;
/// Creates a task that will complete when all of the supplied tasks have completed synchronously.
/// &lt;/summary&gt;
/// &lt;param name="tasks"&gt;The tasks to wait on for completion.&lt;/param&gt;
/// &lt;returns&gt;A task that represents the completion of all of the supplied tasks.&lt;/returns&gt;
public static async Task WhenAllCompleted(this IEnumerable&lt;Func&lt;Task&gt;&gt; tasks, CancellationToken token = default(CancellationToken)) {
    if (tasks == null) throw new ArgumentNullException("tasks");
    var exceptions = new List&lt;Exception&gt;();
    using (var e = tasks.GetEnumerator()) {
        while (e.MoveNext()) {
            if (token.IsCancellationRequested) {
                exceptions.Add(new OperationCanceledException("tasks collection was cancelled", token));
                break;
            }
            try {
                await e.Current();
            } catch (Exception ex) {
                exceptions.Add(ex);
            }
        }
    }
    if (exceptions.Any()) {
        throw new AggregateException(exceptions);
    }
}