美文网首页
xamarin.forms或者android 在其他线程更新UI

xamarin.forms或者android 在其他线程更新UI

作者: 毛毛v5 | 来源:发表于2019-05-08 16:17 被阅读0次

    如果是xmarin.forms,使用:

                    try
                    {
    
                        Xamarin.Forms.Device.BeginInvokeOnMainThread(() => {
                            MessagingCenter.Send(App.Current, "log", e1.Message +"\r\n"+ e1.Source); // 这里更新UI。
                        });
                    }
                    catch (Exception e2)
                    {
                        Console.WriteLine(e2.Message);
                    }
    

    如果是android.

    FusionField.currentActivity.runOnUiThread(new Runnable()    
            {    
                public void run()    
                {    
                    Toast.makeText(getApplicationContext(), , "Update My UI",    
                            Toast.LENGTH_LONG).show();    
                }    
        
            });
    

    相关文章

      网友评论

          本文标题:xamarin.forms或者android 在其他线程更新UI

          本文链接:https://www.haomeiwen.com/subject/nqhvoqtx.html