Greg Bray
Greg Bray

Reputation: 15697

Detect if code is running on background thread or UI (Dispatcher) thread

I have a Windows Phone 7 application that uses the Dispatcher to make sure code gets run on the UI thread, but sometimes I need to know which thread the method was called on.

How can I detect if a method is called from the UI thread or from a background thread? In Silverlight you would use Dispatcher.CheckAccess, but that is not available on Windows Phone 7.

Upvotes: 1

Views: 1440

Answers (1)

Mick N
Mick N

Reputation: 14882

CheckAccess is there, it just doesn't show in intellisense. Code it and you'll see it compiles/runs.

Upvotes: 4

Related Questions