diff --git a/NBitcoin/Utils.cs b/NBitcoin/Utils.cs index 77b622e688..e736311904 100644 --- a/NBitcoin/Utils.cs +++ b/NBitcoin/Utils.cs @@ -326,6 +326,9 @@ public static IEnumerable> Partition(this IEnumerable source, Func //Only take the slow path if cancellation is possible. if (stream is NetworkStream && cancellation.CanBeCanceled) { +#if !NO_SOCKETASYNC + currentReadCount = stream.ReadAsync(buffer, offset + totalReadCount, count - totalReadCount, cancellation).GetAwaiter().GetResult(); +#else var ar = stream.BeginRead(buffer, offset + totalReadCount, count - totalReadCount, null, null); if (!ar.CompletedSynchronously) { @@ -338,6 +341,7 @@ public static IEnumerable> Partition(this IEnumerable source, Func cancellation.ThrowIfCancellationRequested(); currentReadCount = stream.EndRead(ar); +#endif } else {