示例#1
0
 private void Exec(bool inSync)
 {
     try
     {
         PerformStart = DateTime.Now;
         try
         {
             ActionPipe pipe = GetActionPipe();
             if (pipe != null)
             {
                 if (inSync)
                 {
                     pipe.Execute();
                 }
                 else
                 {
                     pipe.StartExecution();
                 }
             }
         }
         finally
         {
             PerformEnd      = DateTime.Now;
             PerformDuration = PerformEnd - PerformStart;
         }
     }
     catch (Exception e)
     {
         MakeErrorReport(e);
     }
 }
示例#2
0
 protected Task()
 {
     Reports          = new List <TaskReport>();
     BeforeActionPipe = new ActionPipe();
     AfterActionPipe  = new ActionPipe();
     WorkItemPriority = WorkItemPriority.Normal;
 }
示例#3
0
        public ActionPipe GetActionPipe()
        {
            var mainPipe = new ActionPipe
            {
                ThreadPool       = ThreadPool,
                WorkItemPriority = WorkItemPriority,
                OnException      = OnException
            };

            PrepareActionPipe(mainPipe);

            var taskPipe = new ActionPipe
            {
                ThreadPool       = mainPipe.ThreadPool,
                WorkItemPriority = mainPipe.WorkItemPriority,
                OnException      = mainPipe.OnException
            };

            taskPipe.Pipe(() => PerformStart = DateTime.Now);
            taskPipe.Pipe(BeforeActionPipe);
            taskPipe.Pipe(mainPipe);
            taskPipe.Pipe(() =>
            {
                PerformEnd      = DateTime.Now;
                PerformDuration = PerformEnd - PerformStart;
            });
            taskPipe.Pipe(MakeReport);
            taskPipe.Pipe(AfterActionPipe);

            return(taskPipe);
        }
示例#4
0
 protected override void PrepareActionPipe(ActionPipe actionPipe)
 {
     actionPipe.Pipe(Preconditions.CheckNotNull(OnExecute));
 }
示例#5
0
 protected abstract void PrepareActionPipe(ActionPipe actionPipe);
示例#6
0
 public ActionPipe Pipe(ActionPipe actionPipe)
 {
     mActionGroups.AddRange(actionPipe.Select(ag => ag.ToList()));
     return(Pipe());
 }