简体   繁体   中英

What is the difference between Dispatcher thread and UI thread

UI线程和Dispatcher线程在WPF中是相同的还是有什么区别?

A Dispatcher is responsible for managing the work for a thread.

The UI thread is the thread that renders the UI.

The UI thread queues work items inside an object called a Dispatcher. The Dispatcher selects work items on a priority basis and runs each one to completion. Every UI thread must have at least one Dispatcher, and each Dispatcher can execute work items in exactly one thread.

From this article. Read it for a more thorough description of the UI Rendering in WPF

UI thread is a general term (it's not specific to WPF) and describes a thread which has UI components associated with it. Usually, there is only one UI thread per application (in which case, it's called the UI thread), but there can be more, if different UI components (usually windows) are associated with different threads.

Dispatcher is the mechanism WPF uses to associate a component with a thread and to execute work on that thread. But there can also be a thread with a Dispatcher , but no associated UI components. In that case, it's a dispatcher thread, but not a UI thread.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM