我们如何在WPF应用程序中进行空闲时间处理?

有没有办法在WPF应用程序中进行空闲时间处理,相当于MFC中的OnIdle事件?

您可以使用DispatcherPriority of ApplicationIdle调度任务(以正常方式使用Dispatcher ,该任务仅在应用程序空闲时执行。

它是Dispatcher.Hooks.DispatcherInactive事件。

一个晚期的替代答案(作为对我自己的备忘录):

 System.Windows.Interop.ComponentDispatcher.ThreadIdle += (_, __) => { Debug.Print("Idle"); };