private void NotifyDestroyingInstance(bool isFinalizer) { try { lock (_instances) { _instances.Remove(Id); } DispatchedHandler notify = () => { try { InstancesChanged?.Invoke(null, ActivitiesCollectionChangedEventArgs.Removed(Id, Instances)); } catch (Exception e) { this.Log().Error("An exception was thrown while notifying instance collection changed.", e); } }; if (isFinalizer) { CoreDispatcher.Main.RunAsync(CoreDispatcherPriority.Normal, notify); } else { notify(); } } catch (Exception e) { this.Log().Error("Failed to remove activity from instances collection.", e); } }
private static async void Setup(Flyout m) { if (Windows.ApplicationModel.DesignMode.DesignModeEnabled) { return; } var s = GetItemsSource(m); if (s == null) { return; } var t = GetItemTemplate(m); if (t == null) { return; } var c = new ItemsControl { ItemsSource = s, ItemTemplate = t, }; var n = CoreDispatcherPriority.Normal; DispatchedHandler h = () => m.Content = c; await m.Dispatcher.RunAsync(n, h); }
public static async Task DispatchEventToUI(CoreDispatcherPriority priority, DispatchedHandler callback) { if (callback != null) { await Windows.ApplicationModel.Core.CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(priority, callback); } }
private void RunDispatched(DispatchedHandler handler) { if (UIDispatcher != null) { UIDispatcher.RunAsync(CoreDispatcherPriority.Normal, handler).AsTask(); } }
public async static void Show(string message, string title, Brush backgroundBrush, Brush foregroundTextBrush, Brush countdownBackgroundBrush, double timeToLive, bool autoHide = false, double width = 300, double height = 180, string metroIcon = "", string imageIcon = "", double scaleIcon = 1) { if (NotificationService._rootControl != null && message != null) { DispatchedHandler invokedHandler = new DispatchedHandler(() => { if (NotificationService._rootControl == null) //|| MsgBoxService._rootControl.Visibility == Visibility.Visible) { return; } NotificationService._rootControl.Visibility = Visibility.Visible; NotificationView view = new NotificationView(message, "", autoHide, timeToLive, metroIcon, iconColor: backgroundBrush, imageIcon: imageIcon, scaleIcon: scaleIcon); view.Width = width; view.Height = height; view.Margin = new Thickness(3); //view.HorizontalAlignment = horizontalAlignment; //view.VerticalAlignment = VerticalAlignment.Top; view.BackgroundFill = backgroundBrush; view.MessageTextForegroundColor = foregroundTextBrush; view.CountdownBackgroundColor = countdownBackgroundBrush; view.Show(); view.OnClosing += new EventHandler(NotificationService.view_OnClosing); NotificationService._MsgboxContainer.Children.Insert(0, view); }); await NotificationService._rootControl.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, invokedHandler); } }
public async static void Show(string message, string title, Brush foregroundTextBrush, Brush countdownBackgroundBrush, double timeToLive, bool autoHide = false, double width = 300, double height = 180, string metroIcon = "", string imageIcon = "", double scaleIcon = 1) { if (NotificationService._rootControl != null && message != null) { DispatchedHandler invokedHandler = new DispatchedHandler(() => { if (NotificationService._rootControl == null) //|| MsgBoxService._rootControl.Visibility == Visibility.Visible) { return; } NotificationService._rootControl.Visibility = Visibility.Visible; NotificationView view = new NotificationView(message, "", autoHide, timeToLive, metroIcon, imageIcon: imageIcon, scaleIcon: scaleIcon); view.Width = width; view.Height = height; view.Margin = new Thickness(3); //view.HorizontalAlignment = horizontalAlignment; //view.VerticalAlignment = VerticalAlignment.Top; view.MessageTextForegroundColor = foregroundTextBrush; view.CountdownBackgroundColor = countdownBackgroundBrush; view.Show(); view.OnClosing += new EventHandler(NotificationService.view_OnClosing); NotificationService._MsgboxContainer.Children.Insert(0, view); }); await NotificationService._rootControl.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, invokedHandler); } }
public async static void RunActionOnUiThread(DispatchedHandler action) { if (dispatcher != null) await dispatcher.RunAsync(CoreDispatcherPriority.Normal, action); else action.Invoke(); }
/// <inheritdoc /> public Task RunAsync(DispatchedHandler callback) { return(Task.Run( () => { this.activity.RunOnUiThread(() => callback()); })); }
public static void RunInUI(DispatchedHandler act) { var disp = CoreApplication.MainView.Dispatcher; if (disp.HasThreadAccess) act.Invoke(); else disp.RunAsync(CoreDispatcherPriority.Normal, act); }
private async Task Dispatch(DispatchedHandler p) { #if !NETFX_CORE await CoreApplication.GetCurrentView().Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, p); #else await CoreApplication.MainView.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, p); #endif }
public async Task RunAsync(DispatchedHandler method) { CoreDispatcher dispatcher = m_dispatcher; if (dispatcher != null) { await dispatcher.RunAsync(CoreDispatcherPriority.Normal, method); } }
/// <summary> /// Runs the handler at idle priority. /// </summary> /// <param name="dispatcher"> /// The <see cref="CoreDispatcher"/> that will run the handler. /// </param> /// <param name="handler"> /// The handler to run. /// </param> /// <returns> /// The <see cref="IAsyncAction"/> that represents the operation. /// </returns> static public IAsyncAction RunIdleAsync(this CoreDispatcher dispatcher, DispatchedHandler handler) { // Validate if (dispatcher == null) throw new ArgumentNullException("dispatcher"); // Run return dispatcher.RunIdleAsync((e) => { handler(); }); }
/// <summary> /// Runs the handler at normal priority. /// </summary> /// <param name="dispatcher"> /// The <see cref="CoreDispatcher"/> that will run the handler. /// </param> /// <param name="handler"> /// The handler to run. /// </param> /// <returns> /// The <see cref="IAsyncAction"/> that represents the operation. /// </returns> static public IAsyncAction RunAsync(this CoreDispatcher dispatcher, DispatchedHandler handler) { // Validate if (dispatcher == null) throw new ArgumentNullException("dispatcher"); // Run return dispatcher.RunAsync(CoreDispatcherPriority.Normal, handler); }
/// <summary> /// Schedules the provided handler on the dispatcher. /// </summary> /// <param name="priority">The execution priority for the handler</param> /// <param name="handler">The handler to execute</param> /// <returns>An async operation for the scheduled handler.</returns> public UIAsyncOperation RunAsync(CoreDispatcherPriority priority, CancellableDispatchedHandler handler) { UIAsyncOperation operation = null; DispatchedHandler nonCancellableHandler = () => handler(operation.Token); return(operation = EnqueueOperation(priority, nonCancellableHandler)); }
protected static Task DispatcherRunAsync(Action action) { var handler = new DispatchedHandler(action); return(CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync( CoreDispatcherPriority.Normal, handler).AsTask()); }
/// <inheritdoc /> public Task RunAsync(DispatchedHandler callback) { return(Task.Run( () => { this.Obj.BeginInvokeOnMainThread(() => callback()); })); }
public async static void Hide() { DispatchedHandler invokedHandler = new DispatchedHandler(() => { InputBoxService._rootControl.Children.Clear(); InputBoxService._rootControl.Visibility = Visibility.Collapsed; }); await InputBoxService._rootControl.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, invokedHandler); }
public void Schedule(DispatchedHandler method) { CoreDispatcher dispatcher = m_dispatcher; if (dispatcher != null) { // Don't want to await the completion Task task = dispatcher.RunAsync(CoreDispatcherPriority.Normal, method).AsTask(); } }
/// <summary> /// Runs the given delegate on the Dispatcher (with the optional priority) /// </summary> /// <param name="method">The method to run on the Dispatcher</param> /// <param name="priority">The Dispatcher priority</param> public static async void RunOnDispatcher(DispatchedHandler method, CoreDispatcherPriority priority = CoreDispatcherPriority.Normal) { if (m_refDispatcher == null) { throw new InvalidOperationException("The service has NOT been initialized"); } await Dispatcher.RunAsync(priority, method); }
public static async void RunActionInCoreWindow(DispatchedHandler handler, BackgroundTaskDeferral deferral = null) { await CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, handler); if (deferral != null) { deferral.Complete(); } }
public static async Task RunOnViewsAsync(DispatchedHandler a) { await MainWindow.CoreView.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, a); if (_childWindows.Count > 0) { await Task.WhenAll(_childWindows.Select(w => w.Value.CoreView.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, a).AsTask())); } }
/// <summary> /// Run operation with 'animation' priority, prior to layout and draw calls. This will run at the beginning of the next UI pass. /// </summary> internal UIAsyncOperation RunAnimation(DispatchedHandler handler) { var operation = new UIAsyncOperation(handler, null); ImmutableInterlocked.Enqueue(ref _animationQueue, operation); QueueOperations(); return(operation); }
public async Task RunAsync(DispatchedHandler dispatchedHandler) { if (_canvasAnimatedControl == null) { throw new InvalidOperationException("This class GameLoopThread is not initialized"); } await _canvasAnimatedControl.RunOnGameLoopThreadAsync(dispatchedHandler); }
/// <summary> /// Runs action on UI thread. /// </summary> /// <param name="onUiThreadDelegate"> /// The UI thread delegate. /// </param> /// <returns> /// The <see cref="IAsyncAction"/>. /// </returns> public static IAsyncAction ApplicationViewAsync(DispatchedHandler onUiThreadDelegate) { return(CoreApplication.MainView.CoreWindow .Dispatcher.RunAsync( CoreDispatcherPriority.Normal, () => { onUiThreadDelegate?.Invoke(); })); }
/// <summary> /// Runs action on UI thread. /// </summary> /// <param name="onUiThreadDelegate"> /// The UI thread delegate. /// </param> /// <returns> /// The <see cref="Task"/>. /// </returns> public static IAsyncAction CurrentViewAsync(DispatchedHandler onUiThreadDelegate) { return(CoreApplication.GetCurrentView() .Dispatcher.RunAsync( CoreDispatcherPriority.Normal, () => { onUiThreadDelegate?.Invoke(); })); }
/// <summary> /// Schedules the provided handler on the dispatcher. /// </summary> /// <param name="priority">The execution priority for the handler</param> /// <param name="handler">The handler to execute</param> /// <returns>An async operation for the scheduled handler.</returns> /// <remarks>Can only be invoked on the UI thread</remarks> internal UIAsyncOperation RunAsync(CoreDispatcherPriority priority, CancellableDispatchedHandler handler) { CoreDispatcher.CheckThreadAccess(); UIAsyncOperation operation = null; DispatchedHandler nonCancellableHandler = () => handler(operation.Token); return(operation = EnqueueOperation(priority, nonCancellableHandler)); }
public DispatchedItem(DispatchedHandler handler, bool isAttended) { this.handler = handler; this.IsAttended = isAttended; if (isAttended) { resetEvent = new ManualResetEvent(false); } }
/// <inheritdoc /> public void Run(DispatchedHandler callback) { if (NSThread.Current.IsMainThread) { callback(); return; } this.Obj.BeginInvokeOnMainThread(() => callback()); }
public static IAsyncAction OnUIThread(DispatchedHandler action) { if (action == null) { throw new ArgumentNullException("action"); } var result = CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, action); return result; }
protected async Task RunInUiThreadIdleAsync(DispatchedHandler action) { if (Dispatcher.HasThreadAccess) { action(); } else { await Dispatcher.RunIdleAsync(a => action()).AsTask().ConfigureAwait(false); } }
/// <summary> /// Runs the specified action on the UI thread. /// </summary> /// <param name="dispatcher">The dispatcher.</param> /// <param name="action">The action to run.</param> /// <param name="coreDispatcherPriority">The core dispatcher priority.</param> internal static async void RunOnUIThread(CoreDispatcher dispatcher, DispatchedHandler action, CoreDispatcherPriority coreDispatcherPriority = CoreDispatcherPriority.Low) { try { await dispatcher.RunAsync(coreDispatcherPriority, action); } catch (Exception ex) { LogFile.Instance.LogError("", "", ex.ToString()); } }
protected async Task RunInUiThreadAsync(DispatchedHandler action) { if (Dispatcher.HasThreadAccess) { action(); } else { await Dispatcher.RunAsync(CoreDispatcherPriority.Low, action).AsTask().ConfigureAwait(false); } }
private static async Task RunInUiThreadAsync(CoreDispatcher dispatcher, DispatchedHandler action) { if (dispatcher.HasThreadAccess) { action(); } else { await dispatcher.RunAsync(CoreDispatcherPriority.Normal, action).AsTask().ConfigureAwait(false); } }
public static IAsyncAction OnUIThread(DispatchedHandler action) { if (action == null) { throw new ArgumentNullException("action"); } var result = CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, action); return(result); }
/// <summary> /// Runs on dispatcher. /// </summary> public static async void RunOnDispatcher(DispatchedHandler action, CoreDispatcher dispatcher = null) { if (dispatcher != null) { await dispatcher.RunAsync(CoreDispatcherPriority.Normal, action).AsTask().ConfigureAwait(false); } else { await CoreApplication.MainView.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, action).AsTask().ConfigureAwait(false); } }
public async static void call(DispatchedHandler fun) { if (Window.Current.Dispatcher.HasThreadAccess) { fun.Invoke(); } else { await Window.Current.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, fun); } }
//--------------------------------------------------------Misc Methods:---------------------------------------------------------------\\ #region --Misc Methods (Public)-- /// <summary> /// Calls the UI thread dispatcher and executes the given callback on it. /// </summary> /// <param name="callback">The callback that should be executed in the UI thread.</param> public static async Task CallDispatcherAsync(DispatchedHandler callback) { if (CoreApplication.MainView.CoreWindow.Dispatcher.HasThreadAccess) { callback(); } else { await CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, callback); } }
/// <summary> /// Runs the event dispatcher on UI thread /// </summary> /// <param name="coreDispatcherPriority"></param> /// <param name="agileCallBack"></param> public async static Task RunAsync(CoreDispatcherPriority coreDispatcherPriority, DispatchedHandler agileCallBack) { //If there is no dispatcher if (Dispatcher == null) Dispatcher = Window.Current.Dispatcher; //If it's already on UI Thread if (Dispatcher.HasThreadAccess) agileCallBack.Invoke(); else await DispatcherHelper.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, agileCallBack); }
private async static void view_OnClosing(object sender, EventArgs e) { DispatchedHandler invokedHandler = new DispatchedHandler(() => { NotificationView mbv = (NotificationView)sender; //MsgBoxService._rootControl.Children.Clear(); NotificationService._MsgboxContainer.Children.Remove(mbv); if (NotificationService._MsgboxContainer.Children.Count == 0) NotificationService._rootControl.Visibility = Visibility.Collapsed; }) ; await NotificationService._rootControl.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, invokedHandler); }
public static IAsyncAction RunAsync(CoreDispatcherPriority prior, DispatchedHandler a) { var d = GetDispatcher(); //if (d.HasThreadAccess) //{ // a.Invoke(); // return ; //} return d.RunAsync(prior, a); }
public static void Appear(FrameworkElement el, int millisecondPostpone = 0) { if (el.GetType().Name == "SplashScreenView") { el.Opacity =1.0; return; } DispatchedHandler invokedHandler = new DispatchedHandler(() => { TranslateTransform translateTransform = new TranslateTransform(); el.RenderTransform = translateTransform; translateTransform.X = (double)Animation.pixelsMove; if (translateTransform != null) { SplineDoubleKeyFrame splineDoubleKeyFrame = new SplineDoubleKeyFrame(); splineDoubleKeyFrame.KeyTime = TimeSpan.FromMilliseconds((double)(10 + millisecondPostpone)); splineDoubleKeyFrame.Value = (double)Animation.pixelsMove; SplineDoubleKeyFrame splineDoubleKeyFrame2 = new SplineDoubleKeyFrame(); splineDoubleKeyFrame2.KeyTime = TimeSpan.FromMilliseconds((double)(350 + millisecondPostpone)); splineDoubleKeyFrame2.Value = 0.0; splineDoubleKeyFrame2.KeySpline = new KeySpline(); splineDoubleKeyFrame2.KeySpline.ControlPoint1 = new Point(0.0, 0.0); splineDoubleKeyFrame2.KeySpline.ControlPoint2 = new Point(0.0, 1.0); DoubleAnimationUsingKeyFrames doubleAnimationUsingKeyFrames = new DoubleAnimationUsingKeyFrames(); Storyboard.SetTarget(doubleAnimationUsingKeyFrames, translateTransform); Storyboard.SetTargetProperty(doubleAnimationUsingKeyFrames, "(TranslateTransform.X)"); doubleAnimationUsingKeyFrames.KeyFrames.Add(splineDoubleKeyFrame); doubleAnimationUsingKeyFrames.KeyFrames.Add(splineDoubleKeyFrame2); SplineDoubleKeyFrame splineDoubleKeyFrame3 = new SplineDoubleKeyFrame(); splineDoubleKeyFrame3.KeyTime = TimeSpan.FromMilliseconds((double)millisecondPostpone); splineDoubleKeyFrame3.Value = 0.0; SplineDoubleKeyFrame splineDoubleKeyFrame4 = new SplineDoubleKeyFrame(); splineDoubleKeyFrame4.KeyTime = TimeSpan.FromMilliseconds((double)(300 + millisecondPostpone)); splineDoubleKeyFrame4.Value = 1.0; DoubleAnimationUsingKeyFrames doubleAnimationUsingKeyFrames2 = new DoubleAnimationUsingKeyFrames(); Storyboard.SetTarget(doubleAnimationUsingKeyFrames2, el); Storyboard.SetTargetProperty(doubleAnimationUsingKeyFrames2, "(UIElement.Opacity)"); doubleAnimationUsingKeyFrames2.KeyFrames.Add(splineDoubleKeyFrame3); doubleAnimationUsingKeyFrames2.KeyFrames.Add(splineDoubleKeyFrame4); Storyboard storyboard = new Storyboard(); storyboard.Children.Add(doubleAnimationUsingKeyFrames); storyboard.Children.Add(doubleAnimationUsingKeyFrames2); storyboard.Begin(); } }); el.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, invokedHandler).GetResults(); }
public async Task RunAlwaysAsync(DispatchedHandler method) { CoreDispatcher dispatcher = m_dispatcher; if (dispatcher != null) { await dispatcher.RunAsync(CoreDispatcherPriority.Normal, method); //System.Threading.Interlocked.Increment(ref m_debugCounter); } else { method(); } }
private static async Task RunInUiThreadAsync(DispatchedHandler action) { try { if (CoreApplication.MainView.CoreWindow.Dispatcher.HasThreadAccess) { action(); } else { await CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, action).AsTask().ConfigureAwait(false); } } catch (Exception ex) { Logger.Add_TPL(ex.ToString(), Logger.PersistentDataLogFilename); } }
/// <summary> /// Executes the specified action on the UI thread /// </summary> /// <param name="agileCallback">The action to execute</param> public static async void RunOnUIThread(DispatchedHandler agileCallback) { var currentWindow = CoreApplication.MainView; if (currentWindow == null) { return; } var dispatcher = currentWindow.Dispatcher; if (dispatcher == null) { return; } await dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { agileCallback.Invoke(); }); }
public static Task RunOnUIThreadAsync(CoreDispatcherPriority priority, DispatchedHandler handler) { if (!DesignMode.DesignModeEnabled) { var dispatcher = Dispatcher; if (dispatcher.HasThreadAccess) { handler.Invoke(); } else { var task = dispatcher.RunAsync(priority, () => { handler(); }).AsTask(); return task; } } return Task.FromResult<object>(null); }
protected async Task RunInUiThreadAsync(DispatchedHandler action) { try { if (Dispatcher.HasThreadAccess) { action(); } else { await Dispatcher.RunAsync(CoreDispatcherPriority.Low, action).AsTask().ConfigureAwait(false); } } catch (InvalidOperationException) // called from a background task: ignore { } catch (Exception ex) { Logger.Add_TPL(ex.ToString(), Logger.PersistentDataLogFilename); } }
/// <summary> /// Runs the specified handler on the UI thread at Normal priority. /// </summary> private async Task CallOnUiThreadAsync(DispatchedHandler handler) => await CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, handler);
private void ShowImage(Image img, bool enableFading) { if (enableFading) { DoubleAnimation animation = new DoubleAnimation { From = new double?(img.Opacity), To = 1.0, Duration = TimeSpan.FromSeconds(0.5) }; animation.SetValue(Storyboard.TargetPropertyProperty, "Opacity"); Storyboard storyboard = new Storyboard(); storyboard.Children.Add(animation); Storyboard.SetTarget(animation, img); storyboard.Completed += (s, e) => { DispatchedHandler handler = new DispatchedHandler(delegate { base.OnProgress(this.GetProgress()); }); base.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, handler); }; storyboard.Begin(); } else { img.Opacity = 1.0; } base.OnProgress(this.GetProgress()); //到处都有你的身影 }
public void Init(TextBlock bar, Border box) { msgBar = bar; msgBox = box; DismissHadler = () => { msgBar.Text = ""; msgBox.Background = DefaultBrush; }; hasInit = true; OnExceptionEvent += OnExceptionMsg; }
/// <summary>${controls_Magnifier_method_onApplyTemplate_D}</summary> protected override void OnApplyTemplate() { base.OnApplyTemplate(); magnifierMap = GetTemplateChild("MagMap") as Map; if (magnifierMap == null) { throw new ArgumentNullException("MagMap"); } //TiledCacheLayer需要 magnifierMap.Layers.LayersInitialized += (s4 , e4) => { ToSetMagnifierLevel(); ToUpdateMagnifierMapCenterPosition(); }; if (Layer != null) { magnifierMap.Layers.Add(Layer); } magnifierMap.MinResolution = double.Epsilon; magnifierMap.MaxResolution = double.MaxValue; //使Map上的Resolutions和magMap的Resolutions保持一致; if (Map != null && Map.Resolutions != null) { magnifierMap.Resolutions = Map.Resolutions; } PointerPressed += (s , e) => { isDragOn = true; beginPosition = e.GetCurrentPoint(null).Position; CapturePointer(e.Pointer); }; PointerMoved += (s2 , e2) => { if (this.isDragOn) { currentPosition = e2.GetCurrentPoint(null).Position; Convert.ToDouble(base.GetValue(Canvas.LeftProperty)); Convert.ToDouble(base.GetValue(Canvas.TopProperty)); MoveTo(currentPosition.X - beginPosition.X , currentPosition.Y - beginPosition.Y); beginPosition = currentPosition; ToUpdateMagnifierMapCenterPosition(); } }; PointerReleased += (s1 , e1) => { if (this.isDragOn) { ReleasePointerCaptures(); isDragOn = false; } }; Opacity = 1.0; if (( Visibility == Visibility.Visible ) && ( Map != null )) { DispatchedHandler handler = new DispatchedHandler(delegate { ToSetMagnifierLevel(); ToUpdateMagnifierMapCenterPosition(); }); Dispatcher.RunAsync(CoreDispatcherPriority.Normal, handler); } }
//public static async void asynCall(int delayMillis, DispatchedHandler fun) { // if (delayMillis > 0) { // await Task.Delay(delayMillis); // } // call(fun); //} public async static void asynCall(DispatchedHandler fun) { await Window.Current.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, fun); }
// Queue code to run on the UI thread and return immediately. private void QueueOnUIThread(DispatchedHandler e) { var ignored = this.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, e); }
public IAsyncAction ExecuteOnUIThread(DispatchedHandler action) { return CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, action); }
/// <summary>${controls_Magnifier_method_ArrangeOverride_D}</summary> protected override Size ArrangeOverride(Size finalSize) { if (base.Visibility == Visibility.Visible) { DispatchedHandler handler = new DispatchedHandler(delegate { ToSetMagnifierLevel(); ToUpdateMagnifierMapCenterPosition(); }); base.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, handler); } return base.ArrangeOverride(finalSize); }
/// <summary> /// Runs code asynchronously on the UI Thread /// </summary> /// <param name="value">The function to be executed</param> /// <returns>The task to wait for the completion of the operation</returns> public async Task RunOnUIAsync(DispatchedHandler value) { await this.coreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, value); }
public async static void call(DispatchedHandler fun) { if (Window.Current.Dispatcher.HasThreadAccess) fun.Invoke(); else await Window.Current.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, fun); }
private void CompositionTarget_Rendering(object sender, object e) { CompositionTarget.Rendering -= new EventHandler<object>(this.CompositionTarget_Rendering); Action a = delegate { base.OnLayerChanged(); this.isInvalidated = false; }; DispatchedHandler handler = new DispatchedHandler(a); base.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, handler); }