I’m currently using Thread.Sleep(2500) to simulate a network call in a mock layer until we can connect to the web services. I have a created a popup with a progress bar (yes, I am using Jeff Wilcox’s progress bar) based on this example, and have gotten the popup to appear successfully. However, I am running into an issue where the popup doesn’t load when I call it after using Thread.Sleep(). The progress bar does not appear until after Thread.Sleep() returns. I’m trying to get this working for an upcoming demo, so I’d like to figure out how to make it work with Thread.Sleep() instead of waiting for the services and hoping it works there.
I’m currently using Thread.Sleep(2500) to simulate a network call in a mock layer until
Share
Your
Thread.Sleepis sleeping the UI thread which is preventing the popup from being displayed until after your method returns. You need can either use theDispatcherTimerclass to get a call back on the UI thread after someTimeSpanhas elapsed, or create a new thread which does the sleep.This is a good lesson for when you do have network operations: don’t block the UI thread.