问题
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:
Nope this is exactly what you should be doing. Mark OnNavigatedTo as async and then execute whatever you need to execute.
来源:https://stackoverflow.com/questions/15064469/windows-phone-call-an-async-method-in-onnavigatedto