Reputation: 3346
I'm developing a Windows Phone 8.1 app. I want to know how to redirect to another xaml page after 5 seconds. I want to perform the following thing: When I click on a Log out button, it should navigate to another page(I can do this quite easily) but what I want is that page should not be displayed more than 5 seconds and it should navigate to some other specific page after 5 seconds.
Upvotes: 0
Views: 1432
Reputation: 3221
DispatcherTimer timer;
private void button_Click(object sender, RoutedEventArgs e)
{
if (timer == null)
{
timer = new DispatcherTimer() { Interval = TimeSpan.FromSeconds(5) };
timer.Tick += Timer_Tick;
timer.Start();
}
}
private void Timer_Tick(object sender, object e)
{
timer.Stop();
Frame.Navigate(typeof(MainPage));//Give your page here
}
Upvotes: 1
Reputation: 2967
using System.Threading.Tasks;
//...
private async void LogOut()
{
await Task.Delay(5000); //wait for 5 seconds asynchronously
//TODO: perform navigate
}
Upvotes: 3