Search code examples
c#windows-phone-7delay

Adding delay in program C#


In my WP7 app, player draws a line and then CPU draws a line. I want CPU to wait for 5 sec before processing and drawing the line. I use this System.Threading.Thread.Sleep(5000);just after player is done drawing. But the player's line is not drawn completely and system goes to sleep and after 5 sec both lines are drawn. How to complete the player's line and then to start the delay ?


Solution

  • System.Threading.Thread.Sleep(5000) will freeze your app and your UI. Your app will surely not pass certification because of this.

    Use DispatcherTimer. Follow this link for more info.