【发布时间】:2019-10-11 05:27:16
【问题描述】:
当我的应用第一次启动时,我需要加载一些以前保存的数据。如果它存在 -> 然后转到 TabbedPage 页面。否则,一个登录页面。
我不确定如何在应用程序的 ctor 甚至其他方法中调用我的异步方法?我该怎么做?
这是我的代码..
namespace Foo
{
public class App : Application
{
public App()
{
Page page;
LoadStorageDataAsync(); // TODO: HALP!
if (Account != null)
{
// Lets show the dashboard.
page = new DashboardPage();
}
else
{
// We need to login to figure out who we are.
page = CreateAuthenticationPage();
}
MainPage = page;
}
... snip ...
}
那么为什么LoadStorageDataAsync 是异步的?因为它是using the library PCLStorage,而且都是异步的。
【问题讨论】:
标签: c# asynchronous async-await xamarin.forms