Skip to content

Commit

Permalink
Compatibility task wait simplified
Browse files Browse the repository at this point in the history
  • Loading branch information
LTRData committed Dec 15, 2023
1 parent e312b55 commit d0679f7
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Library/DiscUtils.Core/Compression/SizedDeflateStream.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<int>)asyncResult).Result;
public override int EndRead(IAsyncResult asyncResult) => ((Task<int>)asyncResult).GetAwaiter().GetResult();

public async override Task<int> ReadAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken)
{
Expand Down
2 changes: 1 addition & 1 deletion Library/DiscUtils.Core/Compression/ZlibStream.cs
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ public override int Read(Span<byte> 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<int>)asyncResult).Result;
public override int EndRead(IAsyncResult asyncResult) => ((Task<int>)asyncResult).GetAwaiter().GetResult();

/// <summary>
/// Seeks to a new position.
Expand Down
4 changes: 2 additions & 2 deletions Library/DiscUtils.Streams/Util/CompatExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<int>)asyncResult).Result;
public override int EndRead(IAsyncResult asyncResult) => ((Task<int>)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();

}

Expand Down
2 changes: 1 addition & 1 deletion Utilities/DiscUtils.Diagnostics/TracingStream.cs
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ public override async ValueTask<int> ReadAsync(Memory<byte> 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<int>)asyncResult).Result;
public override int EndRead(IAsyncResult asyncResult) => ((Task<int>)asyncResult).GetAwaiter().GetResult();

public async override Task<int> ReadAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken)
{
Expand Down

0 comments on commit d0679f7

Please sign in to comment.