1 2 3 4 5 6 7 8 | public static class DispatcherObjectExtensions{ public static TRet myInvoke( this T source, Func func) where T:DispatcherObject { return (TRet)source.Dispatcher.Invoke(func); } public static void myInvoke( this T source, Action act) where T:DispatcherObject { source.Dispatcher.Invoke(act); } } |
This will put these two extension methods on all DispatcherObject descendants (like System.Windows.Window), and you can call a delegate put in the object's thread/context.
No comments :
Post a Comment