In Silverlight, how do you find out whether the code is running in the UI thread or not?

.net, c#, multithreading, silverlight

Solution

You can use the `Dispatcher.CheckAccess` method. It returns true if you're on the same thread as the UI dispatcher, and false otherwise

Problem

Basically I need to know whether I need to can Dispatcher.BeginInvoke or if it's not needed. Thanks.

Original source