Winform 里有 Application.DoEvents();可刷新!
WPF 里没这个,尽管可用委托实现多线程,但是刷新还是不行!
后来找到了 类似App.DoEvents()的方法();
代码:
public partial class App : Application { private static DispatcherOperationCallback exitFrameCallback = new DispatcherOperationCallback(ExitFrame); 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(); } } private static Object ExitFrame (Object state) { DispatcherFrame frame = state as DispatcherFrame; frame.Continue = false; return null; } } }
原文地址:https://www.cnblogs.com/FengShenMeng/p/6054571.html
原文:https://www.cnblogs.com/mqxs/p/15128737.html