问题
I was looking around for refrences using dispatcher to call code on the UI thread and they say to do this:
Dispatcher.BeginInvoke(() => {OnSendSuccessful(); });
But I get a compiler error saying I cant access non-static method BeginInvoke in a static context. Any ideas? I tried to new up a dispatcher but that doesn't even make sense.
回答1:
Try using:
Deployment.Current.Dispatcher.BeginInvoke(() => {OnSendSuccessful(); });
This uses a static method to get a dispatcher for use in a static context.
来源:https://stackoverflow.com/questions/4247729/cant-use-dispatcher-on-wp7