我想要一个简单的方法来检查应用程序何时忙碌以及何时空闲。在做了一些搜索后,我发现了人们建议的两种方法。一个是 GetLastInputInfo 函数,另一个是 Application.Idle。
我只想检测应用程序不活动而不是系统不活动。所以我打算使用Application.Idle。但是现在当应用程序再次激活时如何触发事件?我在空闲事件中启动计时器,我希望在其他功能中重置它。
任何帮助,将不胜感激。
我的事件处理程序:
void Application_Idle(object sender, EventArgs e)
{
System.Timers.Timer aTimer = new System.Timers.Timer(5000);
aTimer.Elapsed += aTimer_Elapsed;
aTimer.Enabled = true;
}