Skip to content

Commit 0c49fdb

Browse files
committed
Fix: Use CancelAsync for CancellationTokenSource in EventCallbackDebouncer to ensure async cancellation
1 parent 272e94f commit 0c49fdb

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/CodeOfChaos.Extensions.AspNetCore.Components/EventCallbacks/EventCallbackDebouncer.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,11 @@ public async ValueTask DisposeAsync() {
5151

5252
await _semaphore.WaitAsync();
5353
try {
54-
_cts?.Cancel();
55-
_cts?.Dispose();
54+
if (_cts is not null) {
55+
await _cts.CancelAsync();
56+
_cts.Dispose();
57+
}
58+
5659
if (_debounceTask is not null) {
5760
try { await _debounceTask; }
5861
catch {

0 commit comments

Comments
 (0)