在WPF中使用invoke

不同Thread間要調用Fun時請服用

類別路徑

using System.Windows.Threading;

網路上爬文表示這樣使用

this.Dispatcher.Invoke((Action)(() =>
{
        // your code or function here.
}));

但實際上我沒法使用在CODE中

最後我用這個方案

Application.Current.Dispatcher.BeginInvoke(DispatcherPriority.Normal, new Action(() => {
                    // your code or function here.
                    conversion.RaiseCanExecuteChanged();
                }));

2016/1/27 發生在使用COM接收資料完成後,在完成的事件中更新Button Command Binding的CanExecute無法主動更新,花一天找資料