/// <summary> /// Raises the <see cref="PropertyChanged"/> event on the UI thread. /// Synchronous when called from the UI thread, asynchronous otherwise. /// </summary> /// <param name="e">Specifies the property that changed.</param> protected void RaisePropertyChanged(PropertyChangedEventArgs e) { if (e.NullReference()) { throw new ArgumentNullException().StoreFileLine(); } void Invoke() { try { this.PropertyChanged?.Invoke(this, e); } catch (Exception ex) { AppBase.EnqueueException(ex); } } if (!UI.InvokeRequired) { Invoke(); } else { UI.BeginInvoke(Invoke); } }
/// <summary> /// Initializes the (Mechanical4) app. /// </summary> /// <param name="eventQueue">The <see cref="EventQueueBase"/> to wrap.</param> protected static new void Initialize(EventQueueBase eventQueue) { AppBase.Initialize(eventQueue); InitializeUnhandledExceptionCatching(); InitializeSystemEvents(); }
/// <summary> /// Raises the <see cref="CanExecuteChanged"/> event asynchronously on the UI thread. /// </summary> /// <returns>The <see cref="Task"/> representing the operation.</returns> public Task RaiseCanExecuteChangedAsync() { return(UI.InvokeAsync(() => { try { this.CanExecuteChanged?.Invoke(this, EventArgs.Empty); } catch (Exception ex) { AppBase.EnqueueException(ex); } })); }
/// <summary> /// Raises the <see cref="PropertyChanged"/> event asynchronously on the UI thread. /// </summary> /// <param name="e">Specifies the property that changed.</param> /// <returns>The <see cref="Task"/> representing the operation.</returns> protected Task RaisePropertyChangedAsync(PropertyChangedEventArgs e) { if (e.NullReference()) { throw new ArgumentNullException().StoreFileLine(); } return(UI.InvokeAsync(() => { try { this.PropertyChanged?.Invoke(this, e); } catch (Exception ex) { AppBase.EnqueueException(ex); } })); }
/// <summary> /// Raises the <see cref="CanExecuteChanged"/> event on the UI thread. /// Synchronous when called from the UI thread, asynchronous otherwise. /// </summary> public void RaiseCanExecuteChanged() { void Invoke() { try { this.CanExecuteChanged?.Invoke(this, EventArgs.Empty); } catch (Exception ex) { AppBase.EnqueueException(ex); } } if (!UI.InvokeRequired) { Invoke(); } else { UI.BeginInvoke(Invoke); } }