c# - Whats the best/safest way to run an async method on pageload? -
i have async method loads data disk (using json).
however, when run method in startuppage() or onnavigatedto() can't use await operator these aren't async methods. code still run, warnings isn't 'awaited'.
is there way of running async method on startup/navigatedto?
you need use async
on onnavigatedto()
avoid warning ..
protected override async void onnavigatedto(navigationeventargs e) { try { if (!app.viewmodel.isdataloaded) { await app.viewmodel.loaddata(); } } catch (exception ex) { ... } }
Comments
Post a Comment