Windows Phone 8.1 and Windows Runtime Apps How to #7 – Thread.Sleep alternative in Windows Phone 8.1 XAML(Windows Runtime) App

In the earlier version of Windows Phone  , you had the option of using Thread.Sleep which can be used to make a function to wait for specific time . It suspends the current thread for the specified time.

If you targeting Windows Phone Store App (Windows runtime XAML)  , you will need to go via the “asynchronous way”.

The System.Threading.Thread.Sleep method exists for Windows Phone 8.1 Silverlight app template but not for the Windows Runtime XAML App templates.

Thread.Sleep alternative in Windows Phone 8.1 XAML(Windows Runtime) App

Below is a sample code snippet demonstrating the usage of the System.Threading.Tasks.Task.Delay method which creates a task that will complete after the specified time.

 TimeSpan time = TimeSpan.FromSeconds(300);
 await System.Threading.Tasks.Task.Delay(time);

Leave A Reply

Your email address will not be published. Required fields are marked *

You May Also Like

This blog post will guide you through several effective methods to troubleshoot and resolve the issue of Microsoft Edge not...
Windows 11 offers a range of audio enhancements that can enrich your listening experience. These enhancements include features like virtual...
Windows 11 brings a fresh and visually stunning design to your desktop, and one of the standout features is the...