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’ll learn about the Win32 Error “0x000019E5 – ERROR_COULD_NOT_RESIZE_LOG” that you get when debugging system erors in...
In this post, you’ll learn about the error “CO_E_DBERROR 0x8004E02B” that is returned when working with COM based APIs or...
In this post, you’ll learn about the Win32 Error “0x000019D0 – ERROR_LOG_BLOCK_VERSION” that you get when debugging system erors in...