public static void InvokeOnMyThread <T>(this T dispatcherObject, Action callback) where T : DispatcherObject { // FIXME obsolete v1.0.5.0 // 2020-06-29 Dispatcher dispatcher = dispatcherObject.Dispatcher; if (DispatcherUtility.IsCurrentlyRunning(dispatcher)) { callback(); } else { dispatcher.Invoke(callback); } }
/// <summary> /// Determines whether the calling thread is the thread associated with (or at least has access to) the <see cref="Dispatcher"/> of this object. /// </summary> /// <typeparam name="T">The type of the dispatcher object.</typeparam> /// <param name="dispatcherObject">The object that is associated with a dispatcher.</param> public static bool IsCurrentThread <T>(this T dispatcherObject) where T : DispatcherObject { Dispatcher dispatcher = dispatcherObject.Dispatcher; return(DispatcherUtility.IsCurrentlyRunning(dispatcher)); }