我m using xamarin forms 2.3.4.247 shared project. In my login page im navigating my page to another. while this page is rendering i
m在主页面显示活动指标。但不幸的是,活动指标被困了几秒钟后第二页loads.i ve tried these codes below and i got nothing.All of these codes are running into an async command.i
m在Android平台上的实际设备中测试我的应用程序。
1
activityIndicator.IsRunnig=true;
new System.Threading.Thread(new System.Threading.ThreadStart(() =>
{
Navigation.PushAsync(new DeviceLoginView());
})).Start();
2
activityIndicator.IsRunnig=true;
Device.BeginInvokeOnMainThread(async () =>
{
await Navigation.PushAsync(new DeviceLoginView());
});
3
activityIndicator.IsRunnig=true;
await Navigation.PushAsync(new DeviceLoginView());
答案 0 :(得分:0)
该问题是因为您的活动指示符位于旧页面的UI中,而不在新页面上,因此当您执行推送时,旧页面不再显示。 为了获得您想要的结果,您可以使用此插件在转换期间保持加载 https://github.com/aritchie/userdialogs
答案 1 :(得分:0)
我终于能够使这个问题成为现实。 您可以在Task.Run()方法中执行所有异步作业,以在新线程中运行所有这些作业,而不是在UI线程中运行