Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't use dispatcher on WP7

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.

like image 418
deanvmc Avatar asked Nov 22 '10 16:11

deanvmc


1 Answers

Try using:

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

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

like image 179
Matt Lacey Avatar answered Oct 30 '22 03:10

Matt Lacey