c# - In WPF, what is the equivalent of Suspend/ResumeLayout() and BackgroundWorker() from Windows Forms -
if in function in code behind, , want implement displaying "loading..." in status bar following makes sense, know winforms nono:
statusbarmessagetext.text = "loading configuration settings..."; loadsettingsgriddata(); statusbarmessagetext.text = "done";
what winforms chapter 1 class 101, form won't display changes user until after entire function completes... meaning "loading" message never displayed user. following code needed.
form1.suspendlayout(); statusbarmessagetext.text = "loading configuration settings..."; form1.resumelayout(); loadsettingsgriddata(); form1.suspendlayout(); statusbarmessagetext.text = "done"; form1.resumelayout();
what best practice dealing fundamental issue in wpf?
best , simplest:
using(var d = dispatcher.disableprocessing()) { /* work... use dispacher.begininvoke... */ }
or
idisposable d; try { d = dispatcher.disableprocessing(); /* work... use dispacher.begininvoke... */ } { d.dispose(); }
Comments
Post a Comment