Dev2.ExtMethods.TaskExtensions.WaitWithPumping C# (CSharp) Method

WaitWithPumping() public static method

Waits for the task to complete execution, pumping in the meantime.
This method is intended for usage with Windows Presentation Foundation.
public static WaitWithPumping ( this task, int millisecondsTimeout = Timeout.Infinite ) : bool
task this The task for which to wait.
millisecondsTimeout int The number of milliseconds to wait, or Infinite (-1) to wait indefinitely.
return bool
        public static bool WaitWithPumping(this Task task, int millisecondsTimeout = Timeout.Infinite)
        {
            if (task == null)
            {
                throw new ArgumentNullException("task");
            }

            var nestedFrame = new DispatcherFrame();
            task.ContinueWith(_ => nestedFrame.Continue = false);
            Dispatcher.PushFrame(nestedFrame);
            return task.Wait(millisecondsTimeout);
        }
    }
TaskExtensions