Application.DoEvents()(WinForms的一部分)
以下是一般的DoEvents类型方法
using System;
using System.Windows.Threading;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Security.Permissions;
namespace Utilites
{
/// <summary>
/// Emulates the VB6 DoEvents to refresh a window during long running events
/// </summary>
public class ScreenEvents
{
[SecurityPermissionAttribute(SecurityAction.Demand, Flags = SecurityPermissionFlag.UnmanagedCode)]
public static void DoEvents()
{
DispatcherFrame frame = new DispatcherFrame();
Dispatcher.CurrentDispatcher.BeginInvoke(DispatcherPriority.Background,
new DispatcherOperationCallback(ExitFrame), frame);
Dispatcher.PushFrame(frame);
}
public static object ExitFrame(object f)
{
((DispatcherFrame)f).Continue = false;
return null;
}
}
}
Run Code Online (Sandbox Code Playgroud)
它不需要知道应用程序.
| 归档时间: |
|
| 查看次数: |
8033 次 |
| 最近记录: |