asynkron / protoactor-dotnet

Proto Actor - Ultra fast distributed actors for Go, C# and Java/Kotlin
http://proto.actor
Apache License 2.0
1.68k stars 284 forks source link

Caching the CancellationToken will prevent ObjectDisposedException race condition #2125

Closed jstnlef closed 4 weeks ago

jstnlef commented 1 month ago

To be a good citizen, it is important that the caller of this method can (and should) call Dispose() on the returned token source. The problem though, is that each time cts.Token was called before, it would try to create a new CancellationToken which means that it could throw an ObjectDisposedException leading to noisy logs.