6
votes

In my WP8 app, I want to call an Async method when the page is navigated to.

I thought about marking the OnNavigatedTo method with async keyword to be like this:

async protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);
            await myAsyncMethod();
        }

is there a better approach to achieve this, is there a problem in labeling OnNavigatedTo with async ?

1

1 Answers

7
votes

Nope this is exactly what you should be doing. Mark OnNavigatedTo as async and then execute whatever you need to execute.