Handle cancellation token disposal with error handling in ChatComponent

This commit is contained in:
Thorsten Sommer 2025-12-29 17:34:56 +01:00
parent 91a302be41
commit a1106d4c40
Signed by: tsommer
GPG Key ID: 371BBA77A02C0108

View File

@ -932,12 +932,19 @@ public partial class ChatComponent : MSGComponentBase, IAsyncDisposable
} }
if (this.cancellationTokenSource is not null) if (this.cancellationTokenSource is not null)
{
try
{ {
if(!this.cancellationTokenSource.IsCancellationRequested) if(!this.cancellationTokenSource.IsCancellationRequested)
await this.cancellationTokenSource.CancelAsync(); await this.cancellationTokenSource.CancelAsync();
this.cancellationTokenSource.Dispose(); this.cancellationTokenSource.Dispose();
} }
catch
{
// ignored
}
}
} }
#endregion #endregion