c# - Change Notification from DispatcherTimer -
just when thought had grasp on wpf change notification, bugger of timer destroyed illusions...
public mymodel _objecttorefresh; public refresher(mymodel objecttorefresh,dispatcher dispatcher) { _objecttorefresh= objecttorefresh; _objecttorefresh.displaymessage = "changenotification works one!"; _timer = new dispatchertimer(timespan.fromseconds(3), dispatcherpriority.background, eh, dispatcher); _timer.start(); } private void eh(object sender, eventargs e) { _objecttorefresh.displaymessage = "this change not show in ui"; } as side note, mymodel implements inotifypropertychanged. now, dispatchertimer running on ui thread? can explain what's going wrong here?
depends. if timer not called on ui thread, pass in wrong dispatcher. need pass in ui dispatcher if want timer function run on ui thread.
Comments
Post a Comment