Here's the code provided by MSDN, although it doesn't appear to be clear on what it's doing:
[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;
}
I've just noticed a similar implementation in some legacy code today where the DoEvents
method was defined. Why do we need this and what does it mean to push a frame onto the dispatcher?