System.Windows.Threading.Dispatcher.PushFrame(System.Windows.Threading.DispatcherFrame)

Here are the examples of the csharp api class System.Windows.Threading.Dispatcher.PushFrame(System.Windows.Threading.DispatcherFrame) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

42 Examples 7

1. Example

Project: WpfIgniter
Source File: Extensions.cs
View license
public static void DoEvents(this Dispatcher dispatcher, DispatcherPriority priority = DispatcherPriority.Background)
        {
            var frame = new DispatcherFrame();
            dispatcher.BeginInvoke(() => frame.Continue = false, priority);
            Dispatcher.PushFrame(frame);
        }

2. Example

View license
public static void DoEvents(DispatcherPriority priority = DispatcherPriority.Background) {
            DispatcherObject dispObj = (Instance ?? DXSplashScreen.SplashContainer.ActiveInfo.SplashScreen);
            if(dispObj == null)
                return;
            DispatcherFrame frame = new DispatcherFrame();
            dispObj.Dispatcher.BeginInvoke(
                priority,
                new DispatcherOperationCallback(ExitFrame),
                frame);
            Dispatcher.PushFrame(frame);
        }

3. Example

View license
public static void DoEvents(DispatcherPriority priority = DispatcherPriority.Background) {
            DispatcherObject dispObj = DXSplashScreen.SplashContainer.ActiveInfo.SplashScreen;
            if(dispObj == null)
                return;
            DispatcherFrame frame = new DispatcherFrame();
            dispObj.Dispatcher.BeginInvoke(
                priority,
                new DispatcherOperationCallback(ExitFrame),
                frame);
            Dispatcher.PushFrame(frame);
        }

4. Example

View license
public static void DoEvents(DispatcherPriority priority) {
            DispatcherFrame frame = new DispatcherFrame();
            Dispatcher.CurrentDispatcher.BeginInvoke(
                priority,
                new DispatcherOperationCallback(ExitFrame),
                frame);
            Dispatcher.PushFrame(frame);
        }

5. Example

View license
private static void DoEvents()
        {
            var frame = new DispatcherFrame();
            Dispatcher.CurrentDispatcher.BeginInvoke(
                DispatcherPriority.Background,
                new Action<DispatcherFrame>(f => f.Continue = false),
                frame);

            Dispatcher.PushFrame(frame);
        }

6. Example

Project: Winium.Mobile
Source File: MainWindow.xaml.cs
View license
public static void ProcessUiTasks()
        {
            var frame = new DispatcherFrame();
            Dispatcher.CurrentDispatcher.BeginInvoke(
                DispatcherPriority.Background, 
                new DispatcherOperationCallback(
                    delegate
                        {
                            frame.Continue = false;
                            return null;
                        }), 
                null);
            Dispatcher.PushFrame(frame);
        }

7. Example

Project: tooll
Source File: App.xaml.cs
View license
[SecurityPermission(SecurityAction.Demand, Flags = SecurityPermissionFlag.UnmanagedCode)]
        public void DoEvents()
        {
            DispatcherFrame frame = new DispatcherFrame();
            Dispatcher.CurrentDispatcher.BeginInvoke(DispatcherPriority.Background,
               new DispatcherOperationCallback(ExitFrame), frame);
            Dispatcher.PushFrame(frame);
        }

8. Example

Project: gitextensions
Source File: FormStatus.cs
View license
public void BeginModal()
        {
            FormStatus.Start();
            Dispatcher.PushFrame(DispatcherFrame);
        }

9. Example

Project: waf
Source File: DispatcherHelperCore.cs
View license
internal static void DoEvents()
        {
            DispatcherFrame frame = new DispatcherFrame();
            Dispatcher.CurrentDispatcher.BeginInvoke(DispatcherPriority.Background,
                new DispatcherOperationCallback(ExitFrame), frame);
            Dispatcher.PushFrame(frame);
        }

10. Example

Project: TumblThree
Source File: DispatcherHelper.cs
View license
[SecurityPermissionAttribute(SecurityAction.Demand, Flags = SecurityPermissionFlag.UnmanagedCode)]
        internal static void DoEvents()
        {
            DispatcherFrame frame = new DispatcherFrame();
            Dispatcher.CurrentDispatcher.BeginInvoke(DispatcherPriority.Background,
                new DispatcherOperationCallback(ExitFrame), frame);
            Dispatcher.PushFrame(frame);
        }

11. Example

Project: TumblThree
Source File: DispatcherHelper.cs
View license
[SecurityPermission(SecurityAction.Demand, Flags = SecurityPermissionFlag.UnmanagedCode)]
        internal static void DoEvents()
        {
            var frame = new DispatcherFrame();
            Dispatcher.CurrentDispatcher.BeginInvoke(DispatcherPriority.Background,
                new DispatcherOperationCallback(ExitFrame), frame);
            Dispatcher.PushFrame(frame);
        }

12. Example

View license
public static void PumpDispatcher()
    {
      // This is dispatcher magic. I'm not 100% sure how it works, but this is the karmic equiv. of
      // Application.DoEvents() in the Winforms world, and allows any items in the dispatchers queue to be processed
      DispatcherFrame f = new DispatcherFrame();
      Dispatcher.CurrentDispatcher.BeginInvoke(DispatcherPriority.ApplicationIdle, new DispatcherOperationCallback((p) =>
      {
        ((DispatcherFrame)p).Continue = false;
        return null;
      }), f);

      Dispatcher.PushFrame(f);
    }

13. Example

View license
public Task<ExecutionResult> Execute(IReplWindow window, string arguments) {
            var delay = new TimeSpan(0, 0, 0, 0, int.Parse(arguments));
            var start = DateTime.UtcNow;
            while ((start + delay) > DateTime.UtcNow) {
                var frame = new DispatcherFrame();
                Dispatcher.CurrentDispatcher.BeginInvoke(
                    DispatcherPriority.Background,
                    new Action<DispatcherFrame>(f => f.Continue = false),
                    frame
                    );
                Dispatcher.PushFrame(frame);
            }
            return ExecutionResult.Succeeded;
        }

14. Example

View license
private static void DoEvents() {
            var frame = new DispatcherFrame();
            Dispatcher.CurrentDispatcher.BeginInvoke(
                DispatcherPriority.Background,
                new Action<DispatcherFrame>(f => f.Continue = false),
                frame
                );
            Dispatcher.PushFrame(frame);
        }

15. Example

View license
public virtual bool Publish(PublishProjectOptions publishOptions, bool async) {
            string p/n ..... /n //View Source file for more details /n }

16. Example

Project: nodejstools
Source File: CommonProjectNode.cs
View license
public virtual bool Publish(PublishProjectOptions publishOptions, bool async)
        {
            /n ..... /n //View Source file for more details /n }

17. Example

Project: RTVS
Source File: TestScript.cs
View license
public static void DoEvents(Dispatcher disp = null) {
            DispatcherFrame frame = new DispatcherFrame();
            if(disp == null) {
                disp = Dispatcher.CurrentDispatcher;
            }

            disp.BeginInvoke(DispatcherPriority.Background, new DispatcherOperationCallback(ExitFrame), frame);
            Dispatcher.PushFrame(frame);
        }

18. Example

Project: roslyn
Source File: InteractiveWindow.cs
View license
private static void DoEvents()
        {
            var frame = new DispatcherFrame();
            Dispatcher.CurrentDispatcher.BeginInvoke(
                DispatcherPriority.Background,
                new Action<DispatcherFrame>(f => f.Continue = false),
                frame);

            Dispatcher.PushFrame(frame);
        }

19. Example

Project: Neutronium
Source File: DispatcherHelper.cs
View license
[SecurityPermission(SecurityAction.Demand, Flags = SecurityPermissionFlag.UnmanagedCode)]
        public static void DoEvents()
        {
            var frame = new DispatcherFrame();
            Dispatcher.CurrentDispatcher.BeginInvoke(DispatcherPriority.Background,
                new DispatcherOperationCallback(ExitFrame), frame);
            Dispatcher.PushFrame(frame);
        }

20. Example

View license
private static void RunAsyncAction(DispatcherPriority priority = DispatcherPriority.ContextIdle)
        {
            DispatcherFrame frame = new DispatcherFrame();
            Dispatcher.CurrentDispatcher.BeginInvoke(priority,
                new DispatcherOperationCallback(f =>
                {
                    ((DispatcherFrame)f).Continue = false;
                    return null;
                }), frame);
            Dispatcher.PushFrame(frame);
        }

21. Example

View license
public static void DispatchFrame(DispatcherPriority priority = DispatcherPriority.Background)
        {
            DispatcherFrame frame = new DispatcherFrame();
            Dispatcher.CurrentDispatcher.BeginInvoke(priority,
                new DispatcherOperationCallback((f)=>((DispatcherFrame)f).Continue = false), frame);
            Dispatcher.PushFrame(frame);
        }

22. Example

View license
public static void ProcessMessages([NotNull] this Dispatcher dispatcher, DispatcherPriority priority)
        {
            Contract.Requires(dispatcher != null);

            var frame = new DispatcherFrame();
            dispatcher.BeginInvoke(priority, () => frame.Continue = false);
            Dispatcher.PushFrame(frame);
        }

23. Example

Project: DNTProfiler
Source File: DispatcherHelper.cs
View license
public static void DoEvents()
        {
            var frame = new DispatcherFrame();
            Dispatcher.CurrentDispatcher.BeginInvoke(DispatcherPriority.Background,
                new DispatcherOperationCallback(dispatcherFrame =>
                {
                    ((DispatcherFrame)dispatcherFrame).Continue = false;
                    return null;
                }), frame);
            Dispatcher.PushFrame(frame);
        }

24. Example

Project: FieldLog
Source File: TaskHelper.cs
View license
public static void DoEvents(DispatcherPriority priority = DispatcherPriority.Background)
		{
			DispatcherFrame frame = new DispatcherFrame();
			Dispatcher.CurrentDispatcher.BeginInvoke(
				priority,
				new DispatcherOperationCallback(ExitFrame), frame);
			Dispatcher.PushFrame(frame);
		}

25. Example

Project: TxTranslation
Source File: TaskHelper.cs
View license
public static void DoEvents(DispatcherPriority priority = DispatcherPriority.Background)
		{
			DispatcherFrame frame = new DispatcherFrame();
			Dispatcher.CurrentDispatcher.BeginInvoke(
				priority,
				new DispatcherOperationCallback(ExitFrame), frame);
			Dispatcher.PushFrame(frame);
		}

26. Example

View license
[SecurityPermissionAttribute(SecurityAction.Demand, Flags = SecurityPermissionFlag.UnmanagedCode)]
            public static void DoEvents() {
                DispatcherFrame frame = new DispatcherFrame();
                Dispatcher.CurrentDispatcher.BeginInvoke(DispatcherPriority.Background,
                    new DispatcherOperationCallback(ExitFrame), frame);
                Dispatcher.PushFrame(frame);
                System.Windows.Forms.Application.DoEvents();
            }

27. Example

Project: roslyn
Source File: DispatcherExtensions.cs
View license
public static void DoEvents(this Dispatcher dispatcher)
        {
            // A DispatcherFrame represents a loop that processes pending work
            // items.
            var frame = new DispatcherFrame();
            var callback = (Action<DispatcherFrame>)(f => f.Continue = false);

            // Executes the specified delegate asynchronously.  When it is 
            // complete mark the frame as complete so the dispatcher loop
            // pops out (stops).
            var operation = dispatcher.BeginInvoke(
                DispatcherPriority.SystemIdle, callback, frame);

            // Start the loop.  It will process all items in the queue, then 
            // will process the above callback.  That callback will tell the
            // loop to then stop processing.
            Dispatcher.PushFrame(frame);

            if (operation.Status != DispatcherOperationStatus.Completed)
            {
                operation.Abort();
            }
        }

28. Example

View license
public static void WaitForPriority()
        {
            // Create new nested message pump.
            var nestedFrame = new DispatcherFrame();

            // Dispatch a callback to the current message queue, when getting called,
            // this callback will end the nested message loop.
            // The priority of this callback should be lower than that of event message you want to process.
            var exitOperation = Dispatcher.CurrentDispatcher.BeginInvoke(
                DispatcherPriority.ContextIdle, ExitFrameCallback, nestedFrame);

            // pump the nested message loop, the nested message loop will immediately
            // process the messages left inside the message queue.
            Dispatcher.PushFrame(nestedFrame);

            // If the "exitFrame" callback is not finished, abort it.
            if (exitOperation.Status != DispatcherOperationStatus.Completed)
            {
                exitOperation.Abort();
            }
        }

29. Example

Project: RTVS
Source File: UIThreadHelper.cs
View license
public void DoEvents() {
            if (TaskUtilities.IsOnBackgroundThread()) {
                DoEventsAsync().WaitAndUnwrapExceptions();
                return;
            }

            var frame = new DispatcherFrame();
            _application.Dispatcher.BeginInvoke(DispatcherPriority.Background, new DispatcherOperationCallback(ExitFrame), frame);
            Dispatcher.PushFrame(frame);
        }

30. Example

Project: roslyn
Source File: DispatcherExtensions.cs
View license
public static void DoEvents(this Dispatcher dispatcher)
        {
            // A DispatcherFrame represents a loop that processes pending work
            // items.
            var frame = new DispatcherFrame();
            var callback = (Action<DispatcherFrame>)(f => f.Continue = false);

            // Executes the specified delegate asynchronously.  When it is 
            // complete mark the frame as complete so the dispatcher loop
            // pops out (stops).
            var operation = dispatcher.BeginInvoke(
                DispatcherPriority.Background, callback, frame);

            // Start the loop.  It will process all items in the queue, then 
            // will process the above callback.  That callback will tell the
            // loop to then stop processing.
            Dispatcher.PushFrame(frame);

            if (operation.Status != DispatcherOperationStatus.Completed)
            {
                operation.Abort();
            }
        }

31. Example

View license
public static void DoEvents(this Application app, DispatcherPriority priority = DispatcherPriority.Background)
        {
            var nestedFrame = new DispatcherFrame();
            var exitOperation = Dispatcher.CurrentDispatcher.BeginInvoke(priority, ExitFrameCallback, nestedFrame);

            try
            {
                //execute all next message
                Dispatcher.PushFrame(nestedFrame);

                //If not completed, will stop it
                if (exitOperation.Status != DispatcherOperationStatus.Completed)
                    exitOperation.Abort();
            }
            catch
            {
                exitOperation.Abort();
            }
        }

32. Example

Project: ATF
Source File: CommonDialog.cs
View license
public bool? ShowDialog()
        {
            if(m_frame != null)
                throw new InvalidOperationException("Already showing dialog");

            var owner = Owner as IDialogSite;
            if(owner == null)
                throw new InvalidOperationException("Owner must implement IDialogSite");
           
            m_dialogResult = null;

            owner.Site.Children.Add(m_dialogContent);
            owner.ShowSite();

            m_frame = new DispatcherFrame();
            Dispatcher.PushFrame(m_frame);

            return m_dialogResult;
        }

33. Example

Project: ATF
Source File: DispatcherExtensions.cs
View license
public static void WaitForPriority(this Dispatcher dispatcher, DispatcherPriority priority)
        {
            DispatcherFrame frame = new DispatcherFrame();
            DispatcherOperation dispatcherOperation = dispatcher.BeginInvoke(priority, new DispatcherOperationCallback(ExitFrameOperation), frame);
            Dispatcher.PushFrame(frame);
            if (dispatcherOperation.Status != DispatcherOperationStatus.Completed)
            {
                dispatcherOperation.Abort();
            }
        }

34. Example

Project: RTVS
Source File: UIThreadHelper.cs
View license
public void DoEvents(int ms) {
            if (ms < 0) {
                throw new ArgumentOutOfRangeException(nameof(ms));
            }

            if (ms == 0) {
                DoEvents();
            } else if (TaskUtilities.IsOnBackgroundThread()) {
                Task.Delay(ms)
                    .ContinueWith(t => DoEventsAsync())
                    .Wait();
            } else {
                var frame = new DispatcherFrame();
                Task.Delay(ms)
                    .ContinueWith(t => _application.Dispatcher.BeginInvoke(DispatcherPriority.Background, new DispatcherOperationCallback(ExitFrame), frame));
                Dispatcher.PushFrame(frame);
            }
        }

35. Example

Project: grove
Source File: ThreadBlocker.cs
View license
private bool BlockOnUiThread(System.Action action)
    {
      var dispather = Dispatcher.CurrentDispatcher;

      if (!dispather.CheckAccess())
        return false;

      Debug.Assert(_frame == null, "Do not reuse existing thread blocker, create a new one instead.");
      _frame = new DispatcherFrame(true);

      action();

      // this will block until completed is called
      Dispatcher.PushFrame(_frame);
      _frame = null;

      return true;
    }

36. Example

Project: 3DNUS
Source File: DispatcherThread.cs
View license
private void Run()
        {
            frame = new DispatcherFrame(true);

            dispatcher = Dispatcher.CurrentDispatcher;

            Action action = () =>
            {
                TaskFactory = new TaskFactory(TaskScheduler.FromCurrentSynchronizationContext());
                startedEvent.Set();
            };

            dispatcher.BeginInvoke(action);

            Dispatcher.PushFrame(frame);
        }

37. Example

Project: WPFContrib
Source File: InlineModalDialog.cs
View license
public void Show()
        {
            ValidateOwner();

            InlineModalDecorator panel = GetModalDecorator(Owner);

            if (panel == null) return;
            panel.AddModal(this, ShowBlurrer);

            if (Animator.IsAnimationEnabled)
            {
                Storyboard dialogAnim = DialogIntroAnimation;
                if (dialogAnim != null)
                {
                    if (dialogAnim.IsFrozen)
                    {
                        dialogAnim = dialogAnim.Clone();
                    }

                    dialogAnim.AttachCompletedEventHandler(OnOpenAnimationCompleted);
                    dialogAnim.Begin(this);
                }
            }
            else
            {
                OpenCompleted();
            }

            _dispatcherFrame = new DispatcherFrame();
            Dispatcher.PushFrame(_dispatcherFrame);

            _isOpen = false;
        }

38. Example

Project: breeze.sharp
Source File: TestFns.cs
View license
public static void RunInWpfSyncContext(Func<Task> function) {
      if (function == null) throw new ArgumentNullException("function");
      var prevCtx = SynchronizationContext.Current;
      try {
        var syncCtx = new DispatcherSynchronizationContext();
        SynchronizationContext.SetSynchronizationContext(syncCtx);

        var task = function();
        if (task == null) throw new InvalidOperationException();

        var frame = new DispatcherFrame();
        var t2 = task.ContinueWith(x => { frame.Continue = false; }, TaskScheduler.Default);
        Dispatcher.PushFrame(frame);   // execute all tasks until frame.Continue == false

        task.GetAwaiter().GetResult(); // rethrow exception when task has failed 
      } finally {
        SynchronizationContext.SetSynchronizationContext(prevCtx);
      }
    }

39. Example

Project: breeze.sharp.samples
Source File: TestFns.cs
View license
public static void RunInWpfSyncContext(Func<Task> function) {
            if (function == null) throw new ArgumentNullException("function");
            var prevCtx = SynchronizationContext.Current;
            try {
                var syncCtx = new DispatcherSynchronizationContext();
                SynchronizationContext.SetSynchronizationContext(syncCtx);

                var task = function();
                if (task == null) throw new InvalidOperationException();

                var frame = new DispatcherFrame();
                var t2 = task.ContinueWith(x => { frame.Continue = false; }, TaskScheduler.Default);
                Dispatcher.PushFrame(frame);   // execute all tasks until frame.Continue == false

                task.GetAwaiter().GetResult(); // rethrow exception when task has failed 
            }
            finally {
                SynchronizationContext.SetSynchronizationContext(prevCtx);
            }
        }

40. Example

Project: clide
Source File: StaFact.cs
View license
public Task<RunSummary> RunAsync (IMessageSink diagnosticMessageSink,
										 IMessageBus m/n ..... /n //View Source file for more details /n }

41. Example

Project: WinDbgCs
Source File: InteractiveWindow.cs
View license
public static void ShowWindow()
        {
            System.Threading.AutoResetEvent windowShown = new System.Threading.AutoResetEvent(false);

            ExecuteInSTA(() =>
            {
                Window window = null;

                try
                {
                    window = new InteractiveWindow();
                    window.Show();
                    windowShown.Set();

                    var _dispatcherFrame = new System.Windows.Threading.DispatcherFrame();
                    window.Closed += (obj, e) => { _dispatcherFrame.Continue = false; };
                    System.Windows.Threading.Dispatcher.PushFrame(_dispatcherFrame);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.ToString());
                }
                finally
                {
                    windowShown.Set();
                }

                window?.Close();
                System.Windows.Threading.Dispatcher.CurrentDispatcher.InvokeShutdown();
            }, waitForExecution: false);
            windowShown.WaitOne();
        }

42. Example

Project: RTVS
Source File: UIThreadHelper.cs
View license
private void RunMainThread(object obj) {
            if (Application.Current != null) {
            /n ..... /n //View Source file for more details /n }