DisplayQueue lets developers using the MDriven Framework defer data-binding display updates so that the user interface does not redraw every intermediate state during a sequence of model changes.
What DisplayQueue does
DisplayQueue is part of the MDriven Framework coding framework. It queues display-update work and processes it asynchronously. This reduces unnecessary user-interface updates when several changes occur in quick succession.
For example, consider a repeated assignment such as:
x:=x+1
When this assignment runs in a loop, the value of x passes through many intermediate values. DisplayQueue avoids forcing a UI update for every iteration. The UI can instead update after queued display work is processed.
This behavior is relevant when your application changes data that is shown through data binding. For information about presenting data in a ViewModel, see Documentation:Showing data and Documentation:ViewModel Editor. For actions that change model data, see Documentation:Actions Editor.
Enable DisplayQueue in WPF
In a WPF application, activate the WPF dequeuer early in application startup:
- Locate the code that runs when your WPF application starts, before the application begins normal UI work.
- Add the following statement:
WPFDequeuer.Active = true;
- Start the application and verify that bound UI values continue to update after model changes.
Activating WPFDequeuer enables the WPF-specific processing of queued display updates.
UI implementation differences
DisplayQueue polling differs between UI implementations. Do not assume that the WPF activation statement applies to another UI technology. Use the dequeueing approach provided by the UI implementation you are integrating.
When to use it
Use DisplayQueue when code can make many successive changes that would otherwise cause repeated bound-control updates. Typical cases include loops and other operations in which an object moves through temporary states before reaching the state you want to show to the user.
For example, if an action increments a displayed value 100 times, updating the display for all 100 intermediate values can cause avoidable UI work. Queuing the display updates prevents those passing states from each requiring a separate UI refresh.
