Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Windows Phone: Call an Async method in OnNavigatedTo

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 ?

like image 836
Mina Wissa Avatar asked Feb 25 '13 10:02

Mina Wissa


1 Answers

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

like image 91
Hermit Dave Avatar answered Oct 22 '22 05:10

Hermit Dave