/// <summary> /// Notifies to the View that the property has changed. Invokes the change on the current view Dispatcher. /// </summary> /// <param name="PropertyName">Name of the property that was changed.</param> public async void NotifyPropertyChanged(string PropertyName) { await _dispatcher.TryRunAsync(CoreDispatcherPriority.Normal, () => { PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(PropertyName)); }); }
public void RunAsync(Action func, bool fallbackToThisThread = false) { // TODO: Uno specific - dispatcher queue is not implemented yet if (false) //dispatcherQueue != null) { //var result = dispatcherQueue.TryEnqueue(() => func()); //if (!result) //{ // if (fallbackToThisThread) // { // func(); // } //} } else if (coreDispatcher != null) { var asyncOp = coreDispatcher.TryRunAsync(CoreDispatcherPriority.Normal, () => func()); asyncOp.Completed = (IAsyncOperation <bool> asyncInfo, AsyncStatus asyncStatus) => { bool reRunOnThisThread = false; if (asyncStatus == AsyncStatus.Completed) { var succeeded = asyncInfo.GetResults(); if (!succeeded) { if (fallbackToThisThread) { reRunOnThisThread = true; } } } if (reRunOnThisThread) { func(); } }; } else { if (fallbackToThisThread) { func(); } } }