25

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.

deanvmc
  • 5,957
  • 6
  • 38
  • 68

1 Answers1

60

Try using:

Deployment.Current.Dispatcher.BeginInvoke(() => {OnSendSuccessful(); });  

This uses a static method to get a dispatcher for use in a static context.

Matt Lacey
  • 65,560
  • 11
  • 91
  • 143