Jaa


Beware Of Intellisense: Some Methods are Hidden like Dispatcher.CheckAccess and Dispatcher.VerifyAccess

Just recently came across the fact that some methods are hidden from intellisense through the use of the [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] attribute. Two that are hidden are System.Windows.Threading.Dispatcher.CheckAccess() and System.Windows.Threading.Dispatcher.VerifyAccess() .  These methods are handy when you have a multi-threaded WPF application and need to insure that you are on the UI thread before databinding or doing some other UI activity. A quick search using reflector didn't surface any other hidden WPF apis, although there are other hidden .NET apis.  Worth noting.

Comments

  • Anonymous
    October 28, 2006
    Any idea why these are marked thus? I happened to run into this very fact in the my WPF course that Pluralsight ran this week near Boston. One of my students ask how to find out if you're on the UI thread, so of course I told him about Dispatcher and these methods. Thing was I couldn't remember the exact names, so I went into Visual Studio and tried to find them with IntelliSense...at which point they weren't there of course. (By the way, the methods of the same name as exposed by DispatcherObject are also hidden in the same way.) I eventually realised what was going on. But the fact that this attribute has (presumably) been put there on purpose suggests that someone doesn't want me calling that API. Why? Is there something we should know? (And would Microsoft prefer it if I removed all mention of these two methods from the slides in the Pluralsight WPF course?..)