If I have an active System.Threading.Timer and I set it to null, is it stopped?
I realize that it is more proper to call .Dispose()
but I would like an
Why would it?
Consider:
System.Threading.Timer t = ...;
System.Threading.Timer q = t;
q = null; // Should this stop it as well?
Setting to null is something you do to a variable, not something you do to an object. The Timer has no way of knowing you set a particular variable to null, and cannot take action on the basis of that.
EDIT:
To address the edit, even in the case of having a sole reference, it is not guaranteed that the Timer will be stopped, as it is possible the GC may not run after the reference has been set to null. This is not entirely unlikely either, the Microsoft .NET implementation uses a generational collector and a static field will likely survive a nursery collection and be promoted to an older generation. If your program has a relatively stable memory profile there may never be a collection of the older generations (and by extension the finalizer will not run until the end of the program).