does nulling a System.Threading.Timer stop it?

后端 未结 4 842
不思量自难忘°
不思量自难忘° 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:30

    No, it will not stop.

    Setting a variable to null does not directly have any side-effects such as stopping a timer. (Unless it's a property)

    Since the timer has other references, the GC will not collect it, and it will never stop.

提交回复
热议问题