WPF应用程序中未触发Application.Idle事件 [英] Application.Idle event not firing in WPF application
问题描述
我正在使用第三方Windows窗体控件,该控件执行一些使用Application.Idle事件延迟"的操作.
I am using a third-party Windows Forms control that performs some actions "delayed" using the Application.Idle event.
现在,我们将应用程序移至WPF,这些操作停止了工作. 我发现System.Windows.Forms.Application.Idle事件未按预期引发.
Now that we're moving our application to WPF, these actions stopped working. I've found that the System.Windows.Forms.Application.Idle event is not raised as expected.
如何在WPF应用程序中激发Idle事件,以便可以继续使用该第三方控件(在WindowsFormsHost中)?不能 不能修改Windows Forms控件.
How can I get the Idle event to fire in a WPF application so that I can continue to use that third-party control (within a WindowsFormsHost)? It is not possible to modify the Windows Forms control.
推荐答案
您应该阅读 MSDN上的此页面,其中描述了WPF应用程序中的消息循环行为.特别是,看起来ComponentDispatcher类可用于捕获ThreadIdle事件,该事件与Windows Forms Application.Idle事件大致相对应.
You should read this page on MSDN which describes the message loop behavior in a WPF application. In particular it looks like the ComponentDispatcher class can be used to catch a ThreadIdle event which would roughly correspond to the Windows Forms Application.Idle event.
然后大概可以使用系统. Windows.Forms.Application.RaiseIdle 方法可按组件期望的那样引发Idle事件.
You could then presumably use the System.Windows.Forms.Application.RaiseIdle method to raise the Idle event as the component expects.
这篇关于WPF应用程序中未触发Application.Idle事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!