C#C
C#3y 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


PING ME IF YOU KNOW (:
Was this page helpful?