2 out of 2 rated this helpful - Rate this topic

Dispatcher.CheckAccess Method

Determines whether the calling thread is the thread associated with this Dispatcher.

Namespace:  System.Windows.Threading
Assembly:  System.Windows (in System.Windows.dll)
public bool CheckAccess()

Return Value

Type: System.Boolean
true if the calling thread is the thread associated with this Dispatcher; otherwise, false.

The following code example demonstrates how to use this method.


private delegate void AddTextDelegate(Panel p, String text);

private void AddText(Panel p, String text)
{
    p.Children.Clear();
    p.Children.Add(new TextBlock { Text = text });
}

private void TestBeginInvokeWithParameters(Panel p)
{
    if (p.Dispatcher.CheckAccess()) AddText(p, "Added directly.");
    else p.Dispatcher.BeginInvoke(
        new AddTextDelegate(AddText), p, "Added by Dispatcher.");
}


Silverlight

Supported in: 5, 4, 3

Silverlight for Windows Phone

Supported in: Windows Phone OS 7.1, Windows Phone OS 7.0

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.

Did you find this helpful?
(1500 characters remaining)
Community Content Add
Annotations FAQ
Dispatcher.CheckAccess not always visible in intellisense
When typing the Dispatcher.CheckAccess in a code window, the CheckAccess method on the Dispatcher may not always be visible in intellisense.
Type it anyway and let the compiler tell you there is an error(if there is one).

regards
GregJF