diff --git a/GenOnlineService/Constants.cs b/GenOnlineService/Constants.cs index 6c18add..03df735 100644 --- a/GenOnlineService/Constants.cs +++ b/GenOnlineService/Constants.cs @@ -1211,7 +1211,11 @@ public async Task SendAsync(byte[] buffer, WebSocketMessageType messageType, Can { try { - cts.Dispose(); + // Disarm the pending CancelAfter timer before disposing to prevent a race condition + // where the timer fires concurrently with Dispose(), causing ObjectDisposedException + // in CancellationTokenSource.ExecuteCallbackHandlers. + cts.CancelAfter(Timeout.InfiniteTimeSpan); + cts.Dispose(); } catch (ObjectDisposedException) {