Example #1
0
        /// <summary>
        /// Resets this Job when completed in preparation for reuse.
        /// <remarks>A Job can become 'completed' either by executing all its code or by being killed.</remarks>
        /// </summary>
        private void ResetOnCompletion() {
            D.Assert(!IsRunning, JobName);
            D.Assert(IsCompleted, JobName);
            JobRunner.StopCoroutine(_coroutine);

            _isPaused = false;
            _jobWasKilled = false;

            jobCompleted = null;
            _customYI = null;
            _childJobStack = null;
            _coroutine = null;
            JobName = "CompletedJob";
        }
Example #2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Job"/> class.
 /// <remarks>Warning: See Note 1 above on the time delay that comes from using the optional delegate jobCompleted.</remarks>
 /// </summary>
 /// <param name="coroutine">The coroutine to execute.</param>
 /// <param name="jobName">Name of the job.</param>
 /// <param name="customYI">Optional custom YieldInstruction.</param>
 /// <param name="toStart">if set to <c>true</c> [to start].</param>
 /// <param name="jobCompleted">Action delegate executed when the job is completed. Contains a
 /// boolean indicating whether the job was killed or completed normally.</param>
 public Job(IEnumerator coroutine, string jobName, APausableKillableYieldInstruction customYI = null, Action<bool> jobCompleted = null) {
     _coroutine = coroutine;
     JobName = jobName;      // My 4.26.16 addition
     _customYI = customYI;   // My 8.12.16 addition
     this.jobCompleted = jobCompleted;
     Start();
 }
Example #3
0
        // 12.6.16 public Start never used as I always start when Job is created
        //public void Start() {   
        //    D.Assert(IsReadyToStart, JobName);
        //    //D.Log(JobName != DefaultJobName, "{0}.Start called.", JobName);
        //    //D.Assert(!_hasCoroutineBeenPreviouslyRun, JobName);
        //    IsRunning = true;
        //    JobRunner.StartCoroutine(Run());
        //    //_hasCoroutineBeenPreviouslyRun = true;
        //    IsReadyToStart = false;
        //}

        /// <summary>
        /// Restarts a Job with the included settings after it has completed a previous job.
        /// </summary>
        /// <param name="coroutine">The coroutine.</param>
        /// <param name="jobName">Name of the job.</param>
        /// <param name="customYI">The custom yield instruction.</param>
        /// <param name="jobCompleted">The job completed delegate.</param>
        public void Restart(IEnumerator coroutine, string jobName, APausableKillableYieldInstruction customYI = null, Action<bool> jobCompleted = null) {
            D.Assert(IsCompleted, jobName);
            _coroutine = coroutine;
            JobName = jobName;
            _customYI = customYI;
            this.jobCompleted = jobCompleted;
            Start();
        }