DispatcherPriority 列舉

定義

描述使用 Dispatcher 叫用作業的優先權。

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

欄位

ApplicationIdle 2

列舉值為 2。 在應用程式閒置時處理作業。

Background 4

列舉值為 4。 在完成所有其他的非閒置作業後處理作業。

ContextIdle 3

列舉值為 3。 在完成背景作業後處理作業。

DataBind 8

列舉值為 8。 以同等於資料繫結的優先權處理作業。

Inactive 0

列舉值為 0。 未處理作業。

Input 5

列舉值為 5。 以同等於輸入的優先權處理作業。

Invalid -1

列舉值為 -1。 優先權無效。

Loaded 6

列舉值為 6。 在完成配置和轉譯時,但剛好於輸入優先權項目接受服務之前處理作業。 當引發載入事件時特別會使用此項目。

Normal 9

列舉值為 9。 以一般優先權處理作業。 這是一般的應用程式優先權。

Render 7

列舉值為 7。 以同等於轉譯的優先權處理作業。

Send 10

列舉值為 10。 在其他非同步作業之前處理作業。 這是最高的優先權。

SystemIdle 1

列舉值為 1。 在系統閒置時處理作業。

範例

下列範例會呼叫 方法, Dispatcher.BeginInvoke 並傳遞具有一個引數的委派。 優先順序會設定為 Normal

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

備註

目前版本的 WPF 中沒有對應的 ApplicationIdle ContextIdle 特定系統狀態或「閒置」。 這兩者仍是有效的優先順序;優先順序為 的 ContextIdle 作業優先順序高於 優先順序為 的 SystemIdle 作業。

Dispatcher如果作業超過 CPU 的特定百分比,則不會對作業的執行進行節流。 節流進程的其中一種方式是使用計時器。

如果作業是以 的優先順序 Send 自行 Dispatcher 張貼 Dispatcher.Invoke ,則作業會略過佇列並立即執行。

適用於