Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cancel BeginInvoke in WPF

In WPF, I am calling This.Dispatcher.BeginInvoke(DispatcherPriority.SystemIdle, mydelegete);

Is there a way to cancel later that BeginInvoke method?

Thanks

like image 223
Ghassan Karwchan Avatar asked Jul 28 '09 00:07

Ghassan Karwchan


People also ask

How do I close a dispatcher?

To make stop dispatcher running on your main application thread you should call return from action passed to Dispatcher. Invoke.

What is dispatcher BeginInvoke?

BeginInvoke(DispatcherPriority, Delegate) Executes the specified delegate asynchronously at the specified priority on the thread the Dispatcher is associated with. BeginInvoke(Delegate, DispatcherPriority, Object[])

What is Dispatcher Invoke In c#?

Invoke(Action, DispatcherPriority) Executes the specified Action synchronously at the specified priority on the thread the Dispatcher is associated with. Invoke(Action) Executes the specified Action synchronously on the thread the Dispatcher is associated with.


1 Answers

Dispatcher.BeginInvoke returns a DispatcherOperation object. If you retain a reference to it, you can use its Abort method to dequeue the operation if it hasn't started executing yet.

like image 51
Pavel Minaev Avatar answered Sep 20 '22 01:09

Pavel Minaev