wpf Dispatcher线程和UI线程有什么区别
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/16494213/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
What is the difference between Dispatcher thread and UI thread
提问by Mohd Ahmed
Is UI thread and Dispatcher thread are same in WPF or is there any difference?
WPF中的UI线程和Dispatcher线程是一样的还是有区别的?
采纳答案by Erno
A Dispatcheris responsible for managing the work for a thread.
一个调度员负责管理工作的线程。
The UI thread is the thread that renders the UI.
UI 线程是呈现 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.
UI 线程在称为 Dispatcher 的对象内对工作项进行排队。Dispatcher 根据优先级选择工作项并运行每个项直至完成。每个 UI 线程必须至少有一个 Dispatcher,并且每个 Dispatcher 可以恰好在一个线程中执行工作项。
From this article. Read it for a more thorough description of the UI Rendering in WPF
回答by svick
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 theUI thread), but there can be more, if different UI components (usually windows) are associated with different threads.
UI 线程是一个通用术语(它不是 WPF 特有的),它描述了一个具有与其关联的 UI 组件的线程。通常情况下,只有一个每个应用程序UI线程(在这种情况下,这就是所谓的UI线程),但可以有更多的,如果不同的UI组件(通常窗户)与不同的线程关联。
Dispatcheris 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.
Dispatcher是 WPF 用于将组件与线程关联并在该线程上执行工作的机制。但也可以有一个线程Dispatcher,但没有关联的 UI 组件。在这种情况下,它是一个调度程序线程,而不是一个 UI 线程。

