eg. in Winforms I would write ...
// on UI Thread BackgroundWorker workerThread = new BackgroundWorker(); workerThread.DoWork += new DoWorkEventHandler(LoadChildren); workerThread.RunWorkerCompleted += new RunWorkerCompletedEventHandler(OnLoadChildrenCompleted); while (workerThread.IsBusy) { Application.DoEvents(); }
In WPF, what is the equivalent of Application.DoEvents in Winforms?
I have a Child property in my ViewModel class. HierarchicalDataTemplate has been configured to read items from the Children property.
TreeView displays nodes. When a user extends node, children from node are generated from the results of this property
public Node Children { get {
So, I would like to run 1. in the background thread and wait for it to complete before returning the results ... maintaining the user interface.
Googling led me to this page, which uses DispatcherFrames to simulate the above method . But that seems to be too much work .. that alludes to "Am I doing it right?"
source share