does nulling a System.Threading.Timer stop it?

后端 未结 4 839
不思量自难忘°
不思量自难忘° 2021-01-04 05:00

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

4条回答
  •  清酒与你
    2021-01-04 05:28

    Not necessarily. Setting it to null, removes any references to it, and relies on the garbage collector to dispose of it.

    If the timer went off before the GC got to it, it would trigger the event.

提交回复
热议问题