Recently I tried to update a WPF Dependency property from a System.Timer thread and received a ”Cross Threading” error. This wasn’t entirely unexpected, as I’d encountered similar issues in Winforms in the past.
In Winforms, methods such as Invoke, BeginInvoke and InvokeRequired are used in order to force code to run on the UI thread.
The absence of these methods (but not the error message) in WPF was disconcerting. Fortunately those methods (and many more) do exist, via an extra object called the “Dispatcher” object that hangs off all Ui Elements.