locked
How can I make my application wait? RRS feed

  • Question

  • User98867 posted

    In my app I have a question with 4 alternatives. Upon answering I would want the UI to show the right answer before navigating back to the previous ContentPage.

    How can I do that "sleep" when the user taps the button (I'm using MVVM and Command). When tapping the button I want to update a label, wait 3 sec and then navigate.

    Tuesday, January 20, 2015 10:02 PM

Answers

  • User181 posted

    Try something like this:

    private async void MyButtonHandler(object sender, EventArgs e)
    {
        // Update UI
        await Task.Delay(TimeSpan.FromSeconds(3));
        // Navigate
    }
    
    • Marked as answer by Anonymous Thursday, June 3, 2021 12:00 AM
    Tuesday, January 20, 2015 10:14 PM