WPF的实时更新
public partial class App : Application
{
#region DoEvent
private static DispatcherOperationCallback exitFrameCallback = new DispatcherOperationCallback(ExitFrame);
private static Object ExitFrame(Object state)
{
DispatcherFrame frame = state as DispatcherFrame;
// Exit the nested message loop.
if (frame != null)
{ frame.Continue = false; }
return null;
}
public static void DoEvents()
{
DispatcherFrame nestedFrame = new DispatcherFrame();
DispatcherOperation exitOperation = Dispatcher.CurrentDispatcher.BeginInvoke(DispatcherPriority.Background, exitFrameCallback, nestedFrame);
Dispatcher.PushFrame(nestedFrame);
if (exitOperation.Status != DispatcherOperationStatus.Completed)
{
exitOperation.Abort();
}
}
#endregion
}
在使用的过程中,可以在 Application.Current.Dispatcher.Invoke中调用来更新了

浙公网安备 33010602011771号