我知道在 .NET中有三种定时器类型(参见 比较.NET Framework 类库中的 Timer 类)。我已经选择了一个线程计时器,因为其他类型可以漂移,如果主线程繁忙,我需要这是可靠的。
The way this timer works in the control of the timer is put on another thread so it can always tick along with the work begin completed on the parent thread when it is not busy.
这个定时控制台应用的问题在于,当定时器在另一个线程上运行时,主线程不会对应用程序做任何事情。
I tried adding a while true
loop, but then the main thread is too busy when the timer does go off.