In C#, where should I keep my timer's reference?
问题 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 main is very simple that I don't know where to keep the reference: class Program { static void Main() { new System.Threading.Thread(myThreadStart).Start(); new System.Threading.Timer(myTimerCallback, new MyStateObject(), 0, 5000); } } I thought about keeping the reference in a static field in the Program class, assuming that static