Click here to Skip to main content
15,887,746 members
Please Sign up or sign in to vote.
2.50/5 (2 votes)
See more:
Hello ,

I am looking for a complete talk on Dispatcher in WPF, like what it is, how many disptacher can exist in a single application and all other details. I am googling it but only basics are there. Not able to find any book or post with too much details on Dispatcher.
Posted
Comments
Afzaal Ahmad Zeeshan 4-Sep-15 16:18pm    
That is why Larry Page invented Google, so that you can search for good content on the internet. :-)
Sergey Alexandrovich Kryukov 4-Sep-15 16:28pm    
The question itself is pretty interesting, but what's preventing you for finding out?
—SA

1 solution

The instances of System.Windows.Threading.Dispatcher are created per thread. The property Dispatcher.CurrentDispatcher returns an instance associated with the calling thread, creating one of it was not yet created before, according the lazy initialization pattern. Please see:
https://msdn.microsoft.com/en-us/library/system.windows.threading.dispatcher.currentdispatcher%28v=vs.110%29.aspx[^],
https://en.wikipedia.org/wiki/Lazy_initialization[^].

It's easy to check up that the references obtained reference different objects if you do it in different threads. You can call this property from several different threads, including the UI thread, and check up the references using System.Object.ReferenceEquals. You will see that the Dispatcher objects are referentially different.

—SA
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900