System.Threading.Timer

Posted runliuv

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了System.Threading.Timer相关的知识,希望对你有一定的参考价值。

GLog.WLog("_thdTimer before");
                _thdTimer = new System.Threading.Timer(new TimerCallback(TimerProc));
                //2秒后开始执行计时器;每3秒执行一次
                _thdTimer.Change(2000,3000);
                GLog.WLog("_thdTimer after");

private void TimerProc(object state)
        {
            try
            {
                GLog.WLog("threading timer tick");
            }
            catch (Exception ex)
            { }
        }

2017-04-24 00:20:34.821 _thdTimer before
2017-04-24 00:20:34.821 _thdTimer after
2017-04-24 00:20:36.827 threading timer tick
2017-04-24 00:20:39.839 threading timer tick
2017-04-24 00:20:42.849 threading timer tick
2017-04-24 00:20:45.861 threading timer tick
2017-04-24 00:20:48.871 threading timer tick
2017-04-24 00:20:51.880 threading timer tick

 

以上是关于System.Threading.Timer的主要内容,如果未能解决你的问题,请参考以下文章

为啥 System.Timers.Timer 能在 GC 中存活,而 System.Threading.Timer 不能?

System.Threading.Timer 杀死 PowerShell 控制台

System.Windows.Forms.TimerSystem.Timers.TimerSystem.Threading.Timer

如何在 C# 中创建计时器而不使用 System.Timers.Timer 或 System.Threading.Timer

System.Threading.Timer:它为啥讨厌我?

System.Threading.Timer 在 25-30 次后停止 [重复]