What to do if you tried DispatcherFrame to simulate DoEvents forms:
You may need to enable System.Security.Permissions and System.Windows.Threading. After that, replace the DoEvents () call after each of your sleep and get the desired result.
[SecurityPermissionAttribute(SecurityAction.Demand, Flags = SecurityPermissionFlag.UnmanagedCode)] public void DoEvents() { DispatcherFrame frame = new DispatcherFrame(); Dispatcher.CurrentDispatcher.BeginInvoke(DispatcherPriority.Background, new DispatcherOperationCallback(ExitFrame), frame); Dispatcher.PushFrame(frame); } public object ExitFrame(object f) { ((DispatcherFrame)f).Continue = false; return null; }
MSDN article link: http://msdn.microsoft.com/en-us/library/system.windows.threading.dispatcher.pushframe.aspx
source share