<p>The <code>System.Windows.Threading.DispatcherObject</code> class (which <code>DependencyObject</code> is based on) contains a useful function, called <code>CheckAccess()</code>, that determines whether or not the code is running on the UI thread.</p>

<p>When I wanted to use it yesterday, I was puzzled to find out that Intellisense didn't show the function (nor <code>VerifyAccess()</code>, which throws an exception when not on the UI thread), even though the MSDN library lists it. I decided to investigate the class using Reflector. It seems that the function in question has an <code>EditorBrowsable(EditorBrowsableState.Never)</code> attribute attached to it. The <code>Dispatcher</code> class, which is used by <code>DispatcherObject</code>, has the same attribute attached to <code>CheckAccess()</code> and <code>VerifyAccess()</code>:</p>

<pre><code>public abstract class DispatcherObject
{
    // ...

    [EditorBrowsable(EditorBrowsableState.Never)]
    public bool CheckAccess();
    [EditorBrowsable(EditorBrowsableState.Never)]
    public void VerifyAccess();

    // ...

    [EditorBrowsable(EditorBrowsableState.Advanced)]
    public Dispatcher Dispatcher { get; }
}


public sealed class Dispatcher
{
    // ...

    [EditorBrowsable(EditorBrowsableState.Never)]
    public bool CheckAccess();
    [EditorBrowsable(EditorBrowsableState.Never)]
    public void VerifyAccess();

    // ...
}
</code></pre>

<p>I don't believe that the application of that attribute is random (or a joke), so my question is: why is it there? Should those methods not be called directly? Then why aren't they <code>protected</code> (or <code>internal</code>, like some of the most useful methods in the WPF)?</p>

[{'answer_id': 17507, 'author': 'Eric Haskins', 'author_id': 100, 'author_profile': 'https://Stackoverflow.com/users/100', 'pm_score': 0, 'selected': False, 'text': '<p>I can\'t find any documentation that says you shouldn\'t use those methods directly, but I haven\'t looked very long.</p>\n\n<p>Also you refer to the EditorVisibleAttribute, which doesn\'t exist. According to Reflector it\'s the <a href="http://msdn.microsoft.com/en-us/library/system.componentmodel.editorbrowsableattribute.aspx" rel="nofollow noreferrer">EditorBrowsableAttribute</a>.</p>\n\n<p>Reflector disassembly:</p>\n\n<pre><code>[EditorBrowsable(EditorBrowsableState.Never)]\npublic bool CheckAccess()\n{\n//CODE\n}\n</code></pre>\n'}, {'answer_id': 158065, 'author': 'Judah Gabriel Himango', 'author_id': 536, 'author_profile': 'https://Stackoverflow.com/users/536', 'pm_score': 4, 'selected': True, 'text': '<p>A Microsoft employee <a href="http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/bd0e6f6c-cadd-48f1-8e1a-163c2f17e4ca/" rel="noreferrer">recently stated</a> CheckAccess is used only for "advanced scenarios", so they hid it from Intellisense.</p>\n\n<blockquote>\n  <p>"CheckAccess and VerifyAccess have\n  always been marked to be not visible,\n  maybe IntelliSense wasn\'t respecting\n  it.  You can use Reflector to confirm.\n  The idea here is that CheckAccess and\n  VerifyAccess are advances scenarios,\n  that normal developers don\'t need.</p>\n  \n  <p>However, I do think that\n  EditorBrowsableState.Advanced would\n  have been a more appropriate level."</p>\n</blockquote>\n\n<p>There\'s a Microsoft Connect case for this shortcoming. <a href="https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=367777" rel="noreferrer">Vote for it</a> if it\'s important to you.</p>\n'}]
['https://Stackoverflow.com/questions/17500', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/2074/']