Cancelling a Task when an object is Finalized
I have a class which starts a Task and want to ensure that the Task stops when the object is garbage collected. I have implemented the IDisposable pattern to ensure that if the object is disposed manually or used within a using block, then the Task stops correctly. However , I cant guarantee that the end user will call Dispose() or use the object within a using block. I know that the Garbage Collector will eventually call the Finalizer - does this mean that the task is left running? public class MyClass : IDisposable { private readonly CancellationTokenSource feedCancellationTokenSource = new