In WPF, I am calling This.Dispatcher.BeginInvoke(DispatcherPriority.SystemIdle, mydelegete);
Is there a way to cancel later that BeginInvoke method?
Thanks
To make stop dispatcher running on your main application thread you should call return from action passed to Dispatcher. Invoke.
BeginInvoke(DispatcherPriority, Delegate) Executes the specified delegate asynchronously at the specified priority on the thread the Dispatcher is associated with. BeginInvoke(Delegate, DispatcherPriority, Object[])
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With