Activity 在 xamarin 表单中导航时指示器卡住

Activity Indicator Stuck while Navigating in xamarin forms

Im using xamarin forms 2.3.4.247 shared project. In my login page im navigating my page to another. while this page is rendering im 在主页中显示 Activity 指示器。但不幸的是 Activity 指示器卡住,几秒钟后第二页 loads.ive tried these codes below and i got nothing.All of these codes are running into an async command.im 在 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());

这个问题是因为你的activity指示器在旧页面的UI而不是在新页面,所以当你推送时旧页面不再显示。 为了得到你想要的结果,你可以使用这个插件在过渡期间保持加载 https://github.com/aritchie/userdialogs

我终于能够解决这个问题了。 您可以在 Task.Run() 方法中完成所有异步作业,以 运行 在新线程中而不是在 UI 线程中