1
0
mirror of https://github.com/JKorf/CryptoExchange.Net.git synced 2026-10-04 02:11:11 +00:00

Added WaitAllAsync extension method

This commit is contained in:
Jkorf
2026-09-25 09:33:45 +02:00
parent 9502db6d58
commit 7a11bd0c5e
+13 -1
View File
@@ -6,6 +6,7 @@ using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis; using System.Diagnostics.CodeAnalysis;
using System.Linq; using System.Linq;
using System.Threading; using System.Threading;
using System.Threading.Tasks;
namespace CryptoExchange.Net.SharedApis namespace CryptoExchange.Net.SharedApis
{ {
@@ -625,7 +626,6 @@ namespace CryptoExchange.Net.SharedApis
.ParallelEnumerateAsync(); .ParallelEnumerateAsync();
} }
/// <summary> /// <summary>
/// Subscribe to trade updates for all capabilities in parallel and return results as they arrive /// Subscribe to trade updates for all capabilities in parallel and return results as they arrive
/// </summary> /// </summary>
@@ -807,5 +807,17 @@ namespace CryptoExchange.Net.SharedApis
.Select(x => x.Capability.SubscribeToUserTradeUpdatesAsync(request, onData, ct)) .Select(x => x.Capability.SubscribeToUserTradeUpdatesAsync(request, onData, ct))
.ParallelEnumerateAsync(); .ParallelEnumerateAsync();
} }
/// <summary>
/// Wait for all results from an IAsyncEnumerable and return them as an array
/// </summary>
public static async Task<T[]> WaitAllAsync<T>(this IAsyncEnumerable<T> enumerable)
{
var result = new List<T>();
await foreach (var itemResult in enumerable.ConfigureAwait(false))
result.Add(itemResult);
return result.ToArray();
}
} }
} }