/// <summary> /// Runs the event dispatcher and awaits for it to complete before returning the results for dispatched events asynchronously. /// </summary> /// <param name="action">The action to call.</param> /// <param name="force">Force dispatcher invokation even if already on UI thread.</param> /// <returns>The <see cref="Task"/> object representing the asynchronous operation.</returns> public Task InvokeOnUiThreadAsync(Action action, bool force) { if (_dispatcher != null && (force || !_dispatcher.HasThreadAccess)) { return(_dispatcher.RunAndAwaitAsync(CoreDispatcherPriority.Normal, action)); } else { action(); return(Task.FromResult(0)); } }
/// <summary> /// Runs the event dispatcher and awaits for it to complete before returning the results for dispatched events asynchronously. /// </summary> /// <typeparam name="T">The return type.</typeparam> /// <param name="dispatcher">The dispatcher.</param> /// <param name="function">The function to call.</param> /// <returns>The <see cref="Task"/> object representing the asynchronous operation.</returns> public static Task <T> RunAndAwaitAsync <T>(this CoreDispatcher dispatcher, Func <T> function) { return(dispatcher.RunAndAwaitAsync(CoreDispatcherPriority.Normal, function)); }
/// <summary> /// Runs the event dispatcher and awaits for it to complete before returning the results for dispatched events asynchronously. /// </summary> /// <param name="dispatcher">The dispatcher.</param> /// <param name="action">The action to call.</param> /// <returns>The <see cref="Task"/> object representing the asynchronous operation.</returns> public static Task RunAndAwaitAsync(this CoreDispatcher dispatcher, Action action) { return(dispatcher.RunAndAwaitAsync(CoreDispatcherPriority.Normal, action)); }