Have I missed something with WPF (and Windows Forms before it) in regards to the need to write a lot of repetitive code when developing multi-threaded applications. Every UI
Simply put, for performance reasons. Why should every GUI app have to take on the performance implications of marshalling code when only those that are multi-threaded require it?
Further, you can design your app to have less cross thread chatter, so that less invoking is necessary.
Also, your code is not particularly efficient. a better approach is:
if ( InvokeRequired ) {
Invoke(new MethodInvoker(this.Function));
} else {
// do code
}
EDIT: I guess my code is more for Windows Forms while yours is for WPF, but the purpose is the same. Windows requires that all control updates occur on the thread that created the control due to thread local storage issues. And this is just not something that should be there for all uses.