即事件队列里,如果有很多事件,那么,优先处理某些事件,能否做到?

解决方案 »

  1.   

    wpf中Dispatcher采用拥有优先级的队列来存储事件,在Invoke和BeginInvoke通过DispatcherPriority来控制优先级
    Invalid The enumeration value is -1. This is an invalid priority.
    Inactive The enumeration value is 0. Operations are not processed.
    SystemIdle The enumeration value is 1. Operations are processed when the system is idle.
    ApplicationIdle The enumeration value is 2. Operations are processed when the application is idle.
    ContextIdle The enumeration value is 3. Operations are processed after background operations have completed.
    Background The enumeration value is 4. Operations are processed after all other non-idle operations are completed.
    Input The enumeration value is 5. Operations are processed at the same priority as input.
    Loaded The enumeration value is 6. Operations are processed when layout and render has finished but just before items at input priority are serviced. Specifically this is used when raising the Loaded event.
    Render The enumeration value is 7. Operations processed at the same priority as rendering.
    DataBind The enumeration value is 8. Operations are processed at the same priority as data binding.
    Normal The enumeration value is 9. Operations are processed at normal priority. This is the typical application priority.
    Send The enumeration value is 10. Operations are processed before other asynchronous operations. This is the highest priority.