0
如何在WPF應用程序中獲取其他線程中滑塊控件的值?從其他線程中的控件獲取值
達到設定值時使用:
public static class ControlExtensions
{
public static void InvokeIfRequired(this Control control, Action action)
{
if (System.Threading.Thread.CurrentThread != control.Dispatcher.Thread)
control.Dispatcher.Invoke(action);
else
action();
}
public static void InvokeIfRequired<T>(this Control control, Action<T> action, T parameter)
{
if (System.Threading.Thread.CurrentThread != control.Dispatcher.Thread)
control.Dispatcher.Invoke(action, parameter);
else
action(parameter);
}
}
方法調用:
ControlExtensions.InvokeIfRequired(_mw, value => _mw.tb_w3.Text = value, godz_w3);