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

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