In C#, where should I keep my timer's reference?

前端 未结 3 2079
暗喜
暗喜 2020-12-31 07:22

The documentation of System.Threading.Timer says that I should keep a live reference for it to avoid it being garbage collected. But where should I do that? My

3条回答
  •  暖寄归人
    2020-12-31 07:49

    I think it is OK to keep is a private static field of your class.

    I would keep this reference as a static field rather than playing with garbage collector.

提交回复
热议问题