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

In this post, you will learn about sync provider notifications in Windows 11 and how to disable or enable it...
In this tutorial, let’s learn how to enable or disable the startup sound in Windows 11. By default, when Windows...
The CameraCaptureTask allows the Windows Phone 7 App to launch the Camera Application . This will be useful when the...