void UIAction(Action action)
{
System.Threading.SynchronizationContext.SetSynchronizationContext(new System.Windows.Threading.DispatcherSynchronizationContext(App.Current.Dispatcher));
System.Threading.SynchronizationContext.Current.Post(_ => action(), null);
}
直接调用即可
UIAction(() =>
{
txtTip.Text = str;
}
);
From: https://blog.csdn.net/shaynerain/article/details/102637269