BADF00D / DisposableFixer

This is a Visual Studio Extension and NuGet package that should identify and fix problems as memleaks while using IDisposables.
Other
35 stars 7 forks source link

CancellationTokenRegistration is an IDisposable that should not be disposed #29

Closed dscopra closed 7 years ago

dscopra commented 7 years ago

Disposing CancellationTokenRegistration is considered as "unregister the callback" and therefore should not be marked as undisposed See msdn: https://msdn.microsoft.com/en-us/library/system.threading.cancellationtokenregistration(v=vs.110).aspx

BADF00D commented 7 years ago

The answer from Noseration on stackoverflow convinced me, that the deregistration should part of your cleanup. Otherwise the lifetime your registration is bound to the parent CancellationtokenSource, which might not be under your control. So I will undo this fix.