有没有办法在 WPF 应用程序中进行空闲时间处理,相当于 MFC 中的 OnIdle 事件?
You can dispatch a task (using the Dispatcher
in the normal way) with a DispatcherPriority
of ApplicationIdle
, which will only be executed when the application is idle. Sample code:
DispatcherPriority priority = DispatcherPriority.ApplicationIdle;
Application.Current.Dispatcher.BeginInvoke(priority, action);
A late alternative answer (as a memo to myself):
System.Windows.Interop.ComponentDispatcher.ThreadIdle += (_, __) =>
{
Debug.Print("Idle");
};
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.