c# - How to Pause Before Performing an Action -


i have need place quick pause in application before performing action (enabling application bar button), unsure of how best accomplish this. lot of processing happening in thread ui updated. once ui updated, scrolling pivot control particular pivot item. pause 1 second, or long takes scroll previous pivot item in pivot control, before allowing application bar button enabled. how might accomplish this? have far follows

// show image , scroll start page if needed if (viewport != null) {     viewport.source = result;     if (editpagepivotcontrol != null && editpagepivotcontrol.selectedindex != 0)     {     //here pivot control told move first item     // (from second on before happens)         editpagepivotcontrol.selectedindex = 0;     }     //a flag determine whether app bar button should enabled     //how pause time takes finish moving     // first pivot item?              if (_wasedited)         ((applicationbariconbutton)applicationbar.buttons[0]).isenabled = true;     } 

try this, using system.windows.threading.dispatchertimer:

if (_wasedited) {    dispatchertimer t = new dispatchertimer(dispatcherpriority.normal, dispatcher);    t.tick += new eventhandler((o,e) =>       ((applicationbariconbutton)applicationbar.buttons[0]).isenabled = true;    t.interval = timespan.frommilliseconds(1000);    t.start(); } 

this wait 1000 milliseconds, come ui thread (since set dispatcher in dispatchertimer constructor) , enable application bar.

if lot, consider making timer member of class.


Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -

debian - 500 Error upon login into Plesk Admin - auth.php3? -