diff --git a/CryptoExchange.Net/SharedApis/SharedUtils.cs b/CryptoExchange.Net/SharedApis/SharedUtils.cs index 58f62c4a..557646dd 100644 --- a/CryptoExchange.Net/SharedApis/SharedUtils.cs +++ b/CryptoExchange.Net/SharedApis/SharedUtils.cs @@ -6,6 +6,7 @@ using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; using System.Linq; using System.Threading; +using System.Threading.Tasks; namespace CryptoExchange.Net.SharedApis { @@ -625,7 +626,6 @@ namespace CryptoExchange.Net.SharedApis .ParallelEnumerateAsync(); } - /// /// Subscribe to trade updates for all capabilities in parallel and return results as they arrive /// @@ -807,5 +807,17 @@ namespace CryptoExchange.Net.SharedApis .Select(x => x.Capability.SubscribeToUserTradeUpdatesAsync(request, onData, ct)) .ParallelEnumerateAsync(); } + + /// + /// Wait for all results from an IAsyncEnumerable and return them as an array + /// + public static async Task WaitAllAsync(this IAsyncEnumerable enumerable) + { + var result = new List(); + await foreach (var itemResult in enumerable.ConfigureAwait(false)) + result.Add(itemResult); + + return result.ToArray(); + } } }