public static void DoEvents()
{
try
{
DispatcherFrame frame = new DispatcherFrame();
Dispatcher.CurrentDispatcher.BeginInvoke(DispatcherPriority.Background,
new DispatcherOperationCallback((f) =>
{
((DispatcherFrame)f).Continue = false;
return null;
}), frame);
Dispatcher.PushFrame(frame);
}
catch (OutOfMemoryException)
{
// TODO: If this Exception is ever hit, we want to handle it by
// cancelling the search. See if there is a clean way of doing that.
MessageBox.Show("Out of memory");
}
}