コード例 #1
0
        private void PerformMission(MissionWrapper mission, IArgumentHolder globalArgumentHolder, Barrier finishingBarrier)
        {
            mission.RunState = RunState.RUNNING;
            var result = mission.ActualMission.Perform(mission.ArgumentHolder);

            globalArgumentHolder.RegisterResult(mission.ActualMission.Name, result);

            foreach (var dependantMission in mission.DependantMissions)
            {
                bool shouldPerform = false;
                lock (dependantMission)
                {
                    dependantMission.ArgumentHolder.RegisterResult(mission.ActualMission.Name, result);
                    dependantMission.UnmetDependencies--;
                    if (dependantMission.UnmetDependencies == 0)
                    {
                        shouldPerform = true;
                    }
                }

                if (shouldPerform)
                {
                    var taskToPerform = dependantMission;
                    Task.Run(() => PerformMission(taskToPerform, globalArgumentHolder, finishingBarrier));
                }
            }

            mission.RunState = RunState.FINISHED;
            finishingBarrier.RemoveParticipant();
        }
コード例 #2
0
            public virtual object Perform(IArgumentHolder holder)
            {
                _isPerformedSemaphore.Release();

                Interlocked.Increment(ref _runCounter);
                Arguments = holder;

                if (_canFinishSemaphore != null)
                {
                    _canFinishSemaphore.WaitOne();
                }

                return(null);
            }
コード例 #3
0
            public override object Perform(IArgumentHolder holder)
            {
                base.Perform(holder);

                return(Value);
            }
コード例 #4
0
 public object Perform(IArgumentHolder argumentHolder)
 {
     return(_missionAction(argumentHolder));
 }