diff --git a/Library/DiscUtils.Core/Compression/SizedDeflateStream.cs b/Library/DiscUtils.Core/Compression/SizedDeflateStream.cs index 2b0491616..a2766a8b4 100644 --- a/Library/DiscUtils.Core/Compression/SizedDeflateStream.cs +++ b/Library/DiscUtils.Core/Compression/SizedDeflateStream.cs @@ -69,7 +69,7 @@ public override int Read(byte[] array, int offset, int count) public override IAsyncResult BeginRead(byte[] buffer, int offset, int count, AsyncCallback callback, object state) => ReadAsync(buffer, offset, count, CancellationToken.None).AsAsyncResult(callback, state); - public override int EndRead(IAsyncResult asyncResult) => ((Task)asyncResult).Result; + public override int EndRead(IAsyncResult asyncResult) => ((Task)asyncResult).GetAwaiter().GetResult(); public async override Task ReadAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken) { diff --git a/Library/DiscUtils.Core/Compression/ZlibStream.cs b/Library/DiscUtils.Core/Compression/ZlibStream.cs index 9bc477bec..09b982444 100644 --- a/Library/DiscUtils.Core/Compression/ZlibStream.cs +++ b/Library/DiscUtils.Core/Compression/ZlibStream.cs @@ -219,7 +219,7 @@ public override int Read(Span buffer) public override IAsyncResult BeginRead(byte[] buffer, int offset, int count, AsyncCallback callback, object state) => ReadAsync(buffer, offset, count, CancellationToken.None).AsAsyncResult(callback, state); - public override int EndRead(IAsyncResult asyncResult) => ((Task)asyncResult).Result; + public override int EndRead(IAsyncResult asyncResult) => ((Task)asyncResult).GetAwaiter().GetResult(); /// /// Seeks to a new position. diff --git a/Library/DiscUtils.Streams/Util/CompatExtensions.cs b/Library/DiscUtils.Streams/Util/CompatExtensions.cs index a8966fafa..a57c7b946 100644 --- a/Library/DiscUtils.Streams/Util/CompatExtensions.cs +++ b/Library/DiscUtils.Streams/Util/CompatExtensions.cs @@ -61,12 +61,12 @@ public override void WriteByte(byte value) => public override IAsyncResult BeginRead(byte[] buffer, int offset, int count, AsyncCallback callback, object state) => ReadAsync(buffer, offset, count, CancellationToken.None).AsAsyncResult(callback, state); - public override int EndRead(IAsyncResult asyncResult) => ((Task)asyncResult).Result; + public override int EndRead(IAsyncResult asyncResult) => ((Task)asyncResult).GetAwaiter().GetResult(); public override IAsyncResult BeginWrite(byte[] buffer, int offset, int count, AsyncCallback callback, object state) => WriteAsync(buffer, offset, count, CancellationToken.None).AsAsyncResult(callback, state); - public override void EndWrite(IAsyncResult asyncResult) => ((Task)asyncResult).Wait(); + public override void EndWrite(IAsyncResult asyncResult) => ((Task)asyncResult).GetAwaiter().GetResult(); } diff --git a/Utilities/DiscUtils.Diagnostics/TracingStream.cs b/Utilities/DiscUtils.Diagnostics/TracingStream.cs index 18677652d..3197af915 100644 --- a/Utilities/DiscUtils.Diagnostics/TracingStream.cs +++ b/Utilities/DiscUtils.Diagnostics/TracingStream.cs @@ -317,7 +317,7 @@ public override async ValueTask ReadAsync(Memory buffer, Cancellation public override IAsyncResult BeginRead(byte[] buffer, int offset, int count, AsyncCallback callback, object state) => ReadAsync(buffer, offset, count, CancellationToken.None).AsAsyncResult(callback, state); - public override int EndRead(IAsyncResult asyncResult) => ((Task)asyncResult).Result; + public override int EndRead(IAsyncResult asyncResult) => ((Task)asyncResult).GetAwaiter().GetResult(); public async override Task ReadAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken) {