別のスレッドからの UI スレッドの更新に関する手法を知っています。
これら 2 つの方法/テクニックがありますが、どちらを使用すればよいですか?
タスクの使用:
var uiTask = Task.Factory.StartNew(() => {
// change something on ui thread
var action = theActionOnUiThread;
if (action != null) {
action();
}
}, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.FromCurrentSynchronizationContext());
ディスパッチャの使用:
Dispatcher.CurrentDispatcher.BeginInvoke(
new Action(() => {
// change something on ui thread
var action = theActionOnUiThread;
if (action != null) {
action();
}
}));