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 });