ようやく WPF の変更通知を把握できたと思ったら、Timer の盗人が私の幻想を壊してしまいました...
public MyModel _objectToRefresh;
public Refresher(MyModel objectToRefresh,Dispatcher dispatcher)
{
_objectToRefresh= objectToRefresh;
_objectToRefresh.DisplayMessage = "ChangeNotification works for this one!";
_timer = new DispatcherTimer(TimeSpan.FromSeconds(3),
DispatcherPriority.Background,
eh,
dispatcher);
_timer.Start();
}
private void eh(object sender, EventArgs e)
{
_objectToRefresh.DisplayMessage = "This Change will not show in the UI";
}
補足として、MyModel
INotifyPropertyChanged を実装します。では、UI スレッドで DispatcherTimer を実行するとどうなるでしょうか。ここで何が問題なのか誰か説明できますか?