コード例 #1
0
 public void Execute(object parameter)
 {
     if (ExecuteAction != null)
     {
         ExecuteAction.Invoke(parameter);
     }
 }
コード例 #2
0
ファイル: DelegateCommand.cs プロジェクト: flyapy/Practices
 public void Execute(object parameter)
 {
     if (ExecuteAction == null)
     {
         return;
     }
     ExecuteAction.Invoke(parameter);
 }
コード例 #3
0
 public async void Execute(object parameter)
 {
     if (CanExecute(parameter))
     {
         ExecuteAction?.Invoke(parameter);
         await ExecuteAsync(parameter);
     }
 }
コード例 #4
0
        /// <summary>
        /// Execute command
        /// </summary>
        public DebugCommandStatus Execute(string[] args)
        {
            if (ExecuteAction == null)
            {
                return(DebugCommandStatus.ACTION_IS_NULL_ERROR);
            }

            return(ExecuteAction.Invoke(this, args));
        }
コード例 #5
0
 public void Execute(object parameter)
 {
     if (parameter == null)
     {
         ExecuteAction?.Invoke();
     }
     else
     {
         ExecuteActionArg?.Invoke(parameter);
     }
 }
コード例 #6
0
        public void Execute(object parameter)
        {
            if (ExecuteAction is null)
            {
                return;
            }

            if (ConvertToType(parameter, out var convertedValue))
            {
                ExecuteAction?.Invoke(convertedValue);
            }
        }
コード例 #7
0
        private int Execute(ExecuteAction executeAction, Action <Exception> notifyAction)
        {
            int result = -1;

            if (ExceptionHandled)
            {
                try
                {
                    result = executeAction.Invoke();
                }
                catch (Exception ex)
                {
                    notifyAction.Invoke(ex);
                }
            }
            else
            {
                result = executeAction.Invoke();
                notifyAction.Invoke(null);
            }
            return(result);
        }
コード例 #8
0
ファイル: Command.cs プロジェクト: NicoMertens/Nc2.Wpf.Base
        public void Execute(Object parameter)
        {
            if (ExecuteAction is not null)
            {
                ExecuteAction.Invoke();
                return;
            }

            if (ExecuteActionWithParameter is not null)
            {
                ExecuteActionWithParameter.Invoke(parameter);
                return;
            }
        }
コード例 #9
0
        private void ProcessOperations()
        {
            while (_actions.Count > 0 && _actions.FindMin().DueTime <= Clock.Now)
            {
                var scheduledTask = _actions.DeleteMin();

                // Check if we should fire the action.
                var args = new ActionSchedulerEventArgs();
                args.State = scheduledTask.State;

                ExecuteAction?.Invoke(this, args);

                if (!args.RescheduleAt.HasValue)
                {
                    scheduledTask.Action(scheduledTask.State);
                }
                else // Reschedule
                {
                    ScheduleAction(args.RescheduleAt.Value, scheduledTask.State, scheduledTask.Action);
                }
            }
        }
コード例 #10
0
ファイル: SimpleCommand.cs プロジェクト: Nagisakurumi/MiraiUI
 public void Execute(object parameter)
 {
     ExecuteAction?.Invoke(parameter);
 }
コード例 #11
0
 public void Execute(Object parameter)
 => ExecuteAction?.Invoke((T)parameter);
コード例 #12
0
        public virtual void Execute(object parameter)
        {
            Action A = () => {
#if DEBUG
                execInTry = false;
#endif
                if (execInTry)
                {
                    try
                    {
                        if (UseTask && OnTaskStart != null)
                        {
                            System.Windows.Application.Current.Dispatcher.Invoke(OnTaskStart, parameter);
                        }
                        ExecuteAction?.Invoke(parameter);
                        if (UseTask && OnTaskEnd != null)
                        {
                            System.Windows.Application.Current.Dispatcher.Invoke(OnTaskEnd, parameter);
                        }
                    }
                    catch (Exception ex)
                    {
                        System.Windows.Application.Current.Dispatcher.Invoke((() => {
                            MessageBox.Show(ex.Message, this.ToString(), MessageBoxButton.OK, MessageBoxImage.Error);
                        }));
                    }
                    finally
                    {
                        try
                        {
                            finaly?.Invoke();
                        }
                        catch (Exception ex)
                        {
                            System.Windows.Application.Current.Dispatcher.Invoke(() => {
                                MessageBox.Show(ex.Message, this.ToString(), MessageBoxButton.OK, MessageBoxImage.Error);
                            });
                        }
                    }
                }
                else
                {
                    if (UseTask && OnTaskStart != null)
                    {
                        System.Windows.Application.Current.Dispatcher.Invoke(OnTaskStart, parameter);
                    }
                    ExecuteAction?.Invoke(parameter);
                    if (UseTask && OnTaskEnd != null)
                    {
                        System.Windows.Application.Current.Dispatcher.Invoke(OnTaskEnd, parameter);
                    }
                    finaly?.Invoke();
                }
            };

            if (UseTask)
            {
                Task.Factory.StartNew(A);
            }
            else
            {
                A();
            }
        }