I am looking to perform this action:
Deployment.Current.Dispatcher.BeginInvoke(() =>
{
... // do some UI specific stuff
});
But instead of sending the lambda expression to the UI thread, I want to send it to a background worker.
The situation is as such, I have a messagebox whose response I need to have to know whether or not to do some additional processing (in this case copy a file).
How can one accomplish this? I am open to a refactor solution of sorts that does not include a lambda expression dispatch.
Thanks for reading
MessageBox runs on the UI thread, so when it returns from its modal display, you're on the UI thread. Dispatching to the UI dispatcher at this point doesn't make sense.
You'd want to run your lambda on a background thread (e.g., ThreadPool.QueueUserWorkItem, via a Task, etc), then when that finishes use the dispatcher to return to the UI thread. But you need the dispatcher from the UI thread; not sure if it is different than the one you mention in your code.