CheckAccess Method
Collapse the table of content
Expand the table of content

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.

Community Additions

ADD
Show:
© 2016 Microsoft