Dispatcher线程和UI线程之间有什么区别

时间:2023-01-20 17:36:34

Is UI thread and Dispatcher thread are same in WPF or is there any difference?

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

2 个解决方案

#1


14  

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

Dispatcher负责管理线程的工作。

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

从这篇文章。阅读它以获得WPF中UI渲染的更全面描述

#2


5  

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.

UI线程是一个通用术语(它不是WPF特有的),并描述了一个具有与之关联的UI组件的线程。通常,每个应用程序只有一个UI线程(在这种情况下,它称为UI线程),但如果不同的UI组件(通常是窗口)与不同的线程相关联,则可能会有更多。

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.

Dispatcher是WPF用于将组件与线程相关联并在该线程上执行工作的机制。但是也可以有一个带Dispatcher的线程,但没有关联的UI组件。在这种情况下,它是一个调度程序线程,但不是UI线程。

#1


14  

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

Dispatcher负责管理线程的工作。

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

从这篇文章。阅读它以获得WPF中UI渲染的更全面描述

#2


5  

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.

UI线程是一个通用术语(它不是WPF特有的),并描述了一个具有与之关联的UI组件的线程。通常,每个应用程序只有一个UI线程(在这种情况下,它称为UI线程),但如果不同的UI组件(通常是窗口)与不同的线程相关联,则可能会有更多。

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.

Dispatcher是WPF用于将组件与线程相关联并在该线程上执行工作的机制。但是也可以有一个带Dispatcher的线程,但没有关联的UI组件。在这种情况下,它是一个调度程序线程,但不是UI线程。