multithreading - how to make the silverlight page to wait for few seconds -


i build silverlight application in showing progress bar before content loaded , need pass progress bar few seconds , need close..

i using system.threading.thread.sleep(1000) makes ui freeze.

i need alternative in silverlight in should not freeze ui , process should wait time...

by default on ui thread, time-consuming task block ui. prevent this, push execution background thread -- 1 way task.factory:

task.factory.startnew( () => {     thread.sleep(1000); }); 

note that, if want ui (which suppose would), you'll need ui thread. (if background thread tries change ui, runtime throw exception.) using dispatcher:

task.factory.startnew( () => {     // sleep on background thread     thread.sleep(1000);      // when complete, return ui thread prevent access violation     application.current.dispatcher.begininvoke( () => {          // ui stuff here     }); }); 

Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -