C
C#2y ago
CrosRoad95

❔ Looking for advise

Hello, I have some collection of objects that implements IDisposable, they internally doing various async things. to save a bit of resource i would like to introduce a cancelation token to them - in constructor it will be created and Dispose method will cancel it. it is okey? do you have better approach example i do
{
using var foo = new Foo() // internally create cancelation token source
foo.DoSomething() // does some stuff that i want to cancel if foo get disposde
} // exit scope, dispose "foo", cancel whatever it was doing
{
using var foo = new Foo() // internally create cancelation token source
foo.DoSomething() // does some stuff that i want to cancel if foo get disposde
} // exit scope, dispose "foo", cancel whatever it was doing
PING ME IF YOU KNOW (:
2 Replies
Anton
Anton2y ago
yes except cancellation token is meant for async things
Accord
Accord2y ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.
Want results from more Discord servers?
Add your server