WPF 中的 DoEvents

在看 MSDN 的时候发现了一段比较实用的代码,能在 WPF 下能执行与System.Windows.Forms.Application.DoEvents方法类似的功能。以下对 MSDN 中的代码进行了微调,微调主要集中在DispatcherPriority.SystemIdle 附近。

Imports System.Security.Permissions  
Imports System.Windows.Threading  

''' <summary>  
''' 处理当前在工作项队列的所有帧。  
''' </summary>  
<SecurityPermissionAttribute(SecurityAction.Demand,   
Flags:=SecurityPermissionFlag.UnmanagedCode)>  
Public Sub DoEvents()  
    Dim frame As New DispatcherFrame()  
    Dispatcher.CurrentDispatcher.BeginInvoke(DispatcherPriority.SystemIdle, Sub(f As 
        DispatcherFrame) f.Continue = False, frame)  
    Dispatcher.PushFrame(frame)  
End Sub

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注

ERROR: si-captcha.php plugin: GD image support not detected in PHP!

Contact your web host and ask them to enable GD image support for PHP.

ERROR: si-captcha.php plugin: imagepng function not detected in PHP!

Contact your web host and ask them to enable imagepng for PHP.

此站点使用Akismet来减少垃圾评论。了解我们如何处理您的评论数据

Content is available under CC BY-SA 3.0 unless otherwise noted.