Xamarin线程内同步

 

 

如果是xmarin.forms,使用:

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

Xamarin.Forms.Device.BeginInvokeOnMainThread 类似WINFORM的BeginInvoke

 

如果是android,使用:

1 FusionField.currentActivity.runOnUiThread(new Runnable()    
2         {    
3             public void run()    
4             {    
5                 Toast.makeText(getApplicationContext(), , "Update My UI",    
6                         Toast.LENGTH_LONG).show();    
7             }    
8     
9         });

 

posted @ 2019-06-22 16:09  Hs冰哥  阅读(314)  评论(0编辑  收藏  举报