コード例 #1
0
        public void Execute()
        {
            NextTry = null;

            if (SyncGroup != null)
            {
                Status = AutomatedTaskStatus.WaitingForLock;
                lock (SyncGroup) DoExecute();
            }
            else
            {
                DoExecute();
            }

            NextTry = LocalTime.Now.Add(Intervals);
        }
コード例 #2
0
        void DoExecute()
        {
            CurrentStartTime = LastRunStart = LocalTime.Now;

            try
            {
                Status = AutomatedTaskStatus.Running;
                Action?.Invoke(this);

                if (RecordSuccess)
                {
                    try { ApplicationEventManager.RecordScheduledTask(Name, CurrentStartTime.Value); }
                    catch { /*Problem in logging*/ }
                }

                Status = AutomatedTaskStatus.CompletedAwaitingNextRun;
            }
            catch (Exception ex)
            {
                // if (!WebTestManager.IsTddExecutionMode())
                {
                    if (RecordFailure)
                    {
                        try { ApplicationEventManager.RecordScheduledTask(Name, CurrentStartTime.Value, ex); }
                        catch { /*Problem in logging*/ }
                    }
                }

                Status = AutomatedTaskStatus.FailedAwaitingNextRun;
            }
            finally
            {
                CurrentStartTime = null;
                LastRunEnd       = LocalTime.Now;
                PersistExecution();
            }
        }