What is the use of a Dispatcher Object in WPF?

后端 未结 2 1849
不思量自难忘°
不思量自难忘° 2020-12-14 17:11

What is the use of a Dispatcher Object in WPF?

2条回答
  •  萌比男神i
    2020-12-14 17:36

    Almost every WPF element has thread affinity. This means that access to such an element should be made only from the thread that created the element. In order to do so, every element that requires thread affinity is derived, eventually, from DispatcherObject class. This class provides a property named Dispatcher that returns the Dispatcher object associated with the WPF element.

    The Dispatcher class is used to perform work on its attached thread. It has a queue of work items and it is in charge of executing the work items on the dispatcher thread.

    You can find on the following link some more details on the subject: http://blogs.microsoft.co.il/blogs/arik/archive/2010/08/12/wpf-inside-out-dispatcher.aspx

提交回复
热议问题