I have a main ViewModel and a UserLoginViewModel. From the User view model I need to show a prompt with Ok/Cancel options. I’ve done it as stated in this link http://www.deanchalk.me.uk/post/WPF-MVVM-e28093-Simple-e28098MessageBoxShowe28099-With-Action-Func.aspx . To avoid Invalid-cross thread exception i used a dispatcher. The code is something like this
mainDispatcher.BeginInvoke(new MessageBoxDelegate
(
(message, title) => { Popup(msg, ""); }
), messageArgs);
where mainDispatcher is the dispatcher of MainView and Popup is of type Func<string, string, MessageBoxResult>
And it works fine. The problem is that I cannot get the results from the BeginInvoke Method. Is there is any way to get the result from the BeginInvoke method?
If is there is not, any suggestions how i can implement this?
Obviously you get the result with a var result = Popup(msg, “”);
You need to evaluate the result within BeginInvoke() because any code below BeginInvoke() runs before BeginInvoke().