Skip to content

Commit

Permalink
Use async overloads when building for .NET 8.
Browse files Browse the repository at this point in the history
  • Loading branch information
Nihlus committed Nov 20, 2023
1 parent 1e085ec commit dcf331b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
8 changes: 8 additions & 0 deletions Backend/Remora.Discord.Gateway/DiscordGatewayClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,11 @@ public async Task<Result> RunAsync(CancellationToken stopRequested)

// Something has gone wrong. Close the socket, and handle it
// Terminate the send and receive tasks
#if NET8_0_OR_GREATER
await _disconnectRequestedSource.CancelAsync();
#else
_disconnectRequestedSource.Cancel();
#endif

// The results of the send and receive tasks are discarded here, because the iteration result will
// contain whichever of them failed if any of them did
Expand Down Expand Up @@ -656,7 +660,11 @@ private async Task<Result> RunConnectionIterationAsync(CancellationToken stopReq
}

// Terminate the send and receive tasks
#if NET8_0_OR_GREATER
await _disconnectRequestedSource.CancelAsync();
#else
_disconnectRequestedSource.Cancel();
#endif

// The results of the send and receive tasks are discarded here, because we know that it's going to be a
// cancellation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,11 @@ public async ValueTask DisposeAsync()
GC.SuppressFinalize(this);

// Signal running responders that they should cancel
#if NET8_0_OR_GREATER
await _responderCancellationSource.CancelAsync();
#else
_responderCancellationSource.Cancel();
#endif

// Prevent further payloads from being written, signalling the readers that they should terminate
_payloadsToDispatch.Writer.Complete();
Expand Down

0 comments on commit dcf331b

Please sign in to comment.