c# - Why does System.Threading.Timer callback successfully update UI? -
i have several system.threading.timers on form application callbacks update ui...successfully - i.e. without throwing errors.
i had built these earlier, before knew ui should not updated on thread other ui thread.
now confused why not throw cross-thread exceptions when updating ui on these separate threading.timer threads?
i changing these callbacks ui updates invoked on ui thread, curious why works.
edit: application winforms application.
i changing these callbacks ui updates invoked on ui thread, curious why works.
if windows forms, works purely luck. updating ui on background thread doesn't consistently work, not throw. in particular, if checkforillegalcrossthreadcalls false, "work", , never throw - though behavior wrong. controls not check every property, items "work" though they're not working correctly, typically introduces bugs can difficult diagnose , correct later.
on side note: if wpf, change value of item bound ui, updating ui, on background thread. wpf binding system automatically marshal ui thread you. not work change part of collection, however.
Comments
Post a Comment