1. 打印线程
// 打印当前线程标识
Console.WriteLine($"-------- {Thread.CurrentThread.ManagedThreadId}");
Console.WriteLine(string.Format("-------- {0},{1}", Thread.CurrentThread.ManagedThreadId, 123));
2. 从子/主线程跳回主线程执行任务,例如刷新UI
Device.BeginInvokeOnMainThread
Task.Delay(3000).ContinueWith((b) =>
{
Device.BeginInvokeOnMainThread(() =>
{
TriangleImage.TranslateTo(viewModel.UiModel.IndicatorWidth * 0.5, 0);
});
});