DispatcherPriority 枚举


描述可通过 Dispatcher 调用操作的优先级。Describes the priorities at which operations can be invoked by way of the Dispatcher.

public enum class DispatcherPriority
public enum DispatcherPriority
type DispatcherPriority = 
Public Enum DispatcherPriority


ApplicationIdle 2

枚举值为 2。The enumeration value is 2. 在应用程序空闲时处理操作。Operations are processed when the application is idle.

Background 4

枚举值为 4。The enumeration value is 4. 在完成所有其他非空闲操作后处理操作。Operations are processed after all other non-idle operations are completed.

ContextIdle 3

枚举值为 3。The enumeration value is 3. 在完成后台操作后处理操作。Operations are processed after background operations have completed.

DataBind 8

枚举值为 8。The enumeration value is 8. 按与数据绑定相同的优先级处理操作。Operations are processed at the same priority as data binding.

Inactive 0

枚举值为 0。The enumeration value is 0. 操作未处理。Operations are not processed.

Input 5

枚举值为 5。The enumeration value is 5. 按与输入相同的优先级处理操作。Operations are processed at the same priority as input.

Invalid -1

枚举值为 -1。The enumeration value is -1. 这是一个无效的优先级。This is an invalid priority.

Loaded 6

枚举值为 6。The enumeration value is 6. 在布局和呈现已完成,即将按输入优先级处理项之前处理操作。Operations are processed when layout and render has finished but just before items at input priority are serviced. 具体来说,此值在引发 Loaded 事件时使用。Specifically this is used when raising the Loaded event.

Normal 9

枚举值为 9。The enumeration value is 9. 按正常优先级处理操作。Operations are processed at normal priority. 这是典型的应用程序优先级。This is the typical application priority.

Render 7

枚举值为 7。The enumeration value is 7. 按与呈现相同的优先级处理操作。Operations processed at the same priority as rendering.

Send 10

枚举值为 10。The enumeration value is 10. 在其他异步操作之前处理操作。Operations are processed before other asynchronous operations. 这是最高优先级。This is the highest priority.

SystemIdle 1

枚举值为 1。The enumeration value is 1. 在系统空闲时处理操作。Operations are processed when the system is idle.


下面的示例调用Dispatcher.BeginInvoke方法并向其传递一个具有一个参数的委托。The following example calls the Dispatcher.BeginInvoke method and passes it a delegate with one argument. 优先级设置为NormalThe priority is set to Normal.

// Schedule the update function in the UI thread.
    new OneArgDelegate(UpdateUserInterface), 
' Schedule the update function in the UI thread.
tomorrowsWeather.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Normal, New OneArgDelegate(AddressOf UpdateUserInterface), weather)


在 WPF 的当前版本中ApplicationIdle , 没有与和ContextIdle对应的特定系统状态或 "空闲"。There is no specific system state or "idleness" corresponding to ApplicationIdle and ContextIdle in the current version of WPF. 两者仍是有效优先级;优先级为的ContextIdle操作的优先级高于优先级为的SystemIdle操作。Both are still valid priorities; an operation with a priority of ContextIdle has a higher priority than an operation with a priority of SystemIdle.

如果Dispatcher操作超过一定百分比的 CPU, 则不会限制操作的执行。The Dispatcher does not throttle the execution of an operation if it exceeds a certain percentage of the CPU. 限制进程使用计时器的一种方法。One way to throttle a process it to use a timer.

如果按照的优先级Dispatcher.Invoke Dispatcher使用自己的操作发布操作,则该操作将绕过队列并立即执行。SendIf an operation is posted using Dispatcher.Invoke on its own Dispatcher at a priority of Send, the operation bypasses the queue and is immediately executed.