private bool SetWaitMouseCursor() { if (IsBusy) { return(false); } lock (_synlock) { if (IsBusy) { return(false); } IsBusy = true; if (_previous == null) { CurrentDispatcher.Invoke(() => { _previous = Mouse.OverrideCursor; Mouse.OverrideCursor = Cursors.Wait; }); return(true); } return(false); } }
public override IMessage Invoke(IMessage msg) { try { IMethodMessage mm = msg as IMethodMessage; IMethodCallMessage methodCall = (IMethodCallMessage)msg; if (mm.MethodName == "GetType") { return(new ReturnMessage( typeof(INotifyCollection <T>), null, 0, mm.LogicalCallContext, (IMethodCallMessage)msg)); } MethodInfo method = (MethodInfo)mm.MethodBase; object[] args = mm.Args; object ret = CurrentDispatcher.Invoke(() => { return(method.Invoke(Collection, methodCall.InArgs)); }); return(new ReturnMessage( ret, null, 0, mm.LogicalCallContext, (IMethodCallMessage)msg)); } catch (Exception e) { throw; } }
public void InvokeAutomaticRefresh() { if (AutomaticRefreshOn && IsIdle && AutomaticRefreshSubscriber != null) { CurrentDispatcher.Invoke(() => AutomaticRefreshSubscriber.OnAutomaticRefreshTriggered()); Countdown.ResetCountdown(); } }
public void Execute(Action action) { if (action == null) { return; } CurrentDispatcher.Invoke(action); }
public void InvokeOnUIThread(Action action) { if (CurrentDispatcher.CheckAccess()) { action(); } else { CurrentDispatcher.Invoke(action); } }
private void SetDefaultMouseCursor() { if (!IsBusy) { return; } lock (_synlock) { if (!IsBusy) { return; } IsBusy = false; CurrentDispatcher.Invoke(() => Mouse.OverrideCursor = _previous); _previous = null; } }
private void RaiseStateMachineException(StateMachineExceptionEventArgs e) { var handler = StateMachineException; if (handler == null) { return; } Action action = () => handler(this, e); if (CurrentDispatcher != null) { CurrentDispatcher.Invoke(action, null); } else { action(); } }
private void RaiseStateMachineStopped() { var handler = StateMachineStopped; if (handler == null) { return; } Action action = () => handler(this, EventArgs.Empty); if (CurrentDispatcher != null) { CurrentDispatcher.Invoke(action, null); } else { action(); } }
private void RaiseStateChanged(StateChangedEventArgs <T> e) { var handler = StateChanged; if (handler == null) { return; } Action action = () => handler(this, e); if (CurrentDispatcher != null) { CurrentDispatcher.Invoke(action, null); } else { action(); } }
public void LoadChildren() { if (_object != null) { // exclude value types and strings from listing child members if (!IsPrintableType(_type)) { var propLoad = Task.Run(() => GetPropsandFiels()); // if this is a collection type, add the contained items to the children var colLoad = Task.Run(() => CollectionLoad()); _children = new List <ObjectViewModel>(); _children.AddRange(propLoad.Result); CurrentDispatcher.Invoke(() => NotifyPropertyChanged("Children")); _children.AddRange(colLoad.Result); CurrentDispatcher.Invoke(() => NotifyPropertyChanged("Children")); _children = _children.OrderBy(x => x.Name).ToList(); CurrentDispatcher.Invoke(() => NotifyPropertyChanged("Children")); } } }
internal void TransitionStateInternal <TTrigger>(T fromState, T toState, TTrigger trigger, Action <TTrigger> transitionAction) { //we have to check, that the same event may only come in once. this solves an issue with the tracking mechanism if (trigger is EventArgs) { if (trigger.Equals(_lastTrigger)) { _lastTrigger = trigger; return; } _lastTrigger = trigger; } TransitionOverride(fromState, toState, trigger); if (!CurrentState.Equals(fromState)) { return; } var isInternalTransition = fromState.Equals(toState); Task <bool> vsmTransition = null; if (!isInternalTransition && AssociatedVisualStateManager != null) { vsmTransition = AssociatedVisualStateManager.TransitionState(Name, fromState.ToString(), toState.ToString()); } var currentState = GetState(fromState); var futureState = GetState(toState); //exit the current state if (!isInternalTransition) { currentState.IgnoreTransitions(); currentState.Exit(toState); } //call the transition action if (transitionAction != null) { Action safeAction = () => { try { transitionAction(trigger); } catch (Exception e) { RaiseStateMachineException(e); } }; if (CurrentDispatcher != null) { CurrentDispatcher.Invoke(safeAction, null); } else { safeAction(); } } //enter the next state if (!isInternalTransition) { futureState.Enter(fromState); futureState.ResumeTransitions(); CurrentState = toState; RaiseStateChanged(fromState, toState); } //we can only make automatic transitions if we entered the current state from somewhere else if (!isInternalTransition) { if (vsmTransition == null || vsmTransition.IsCompleted) { futureState.TryAutomaticTransition(); } else { vsmTransition.ContinueWith(result => futureState.TryAutomaticTransition()); } } }
protected object DispatcherInvoke(Action action) { return(CurrentDispatcher.Invoke(CurrentDispatcherPriority, action)); }
protected TT DispatcherInvoke <TT>(Func <TT> func) { return(CurrentDispatcher.Invoke(func, CurrentDispatcherPriority)); }