/// <summary>
        /// Wait for a free performer.
        /// </summary>
        /// <returns>The free performer.</returns>
        public IConcurrentTrainingPerformer WaitForFreePerformer(TrainingJob job)
        {
            IConcurrentTrainingPerformer result = null;

            while (result == null)
            {
                foreach (IConcurrentTrainingPerformer performer in this.performers)
                {
                    if (performer.Ready)
                    {
                        lock (this.accessLock)
                        {
                            performer.Perform(job);
                            result = performer;
                        }
                    }
                }

                if (result == null)
                {
                    this.mightBeDone.WaitOne();
                }
            }

            return(result);
        }
 /// <summary>
 /// Add a performer.
 /// </summary>
 /// <param name="performer">The performer to add.</param>
 public void AddPerformer(IConcurrentTrainingPerformer performer)
 {
     lock (this.accessLock)
     {
         this.performers.Add(performer);
         performer.Manager = this;
     }
 }
예제 #3
0
 /// <summary>
 /// Construct the task runner.
 /// </summary>
 /// <param name="owner">The owner.</param>
 public PerformerTask(IConcurrentTrainingPerformer owner)
 {
     this.owner = owner;
 }
        /// <summary>
        /// Add a performer. 
        /// </summary>
        /// <param name="performer">The performer to add.</param>
        public void AddPerformer(IConcurrentTrainingPerformer performer)
        {
            lock (this.accessLock)
            {
                this.performers.Add(performer);
                performer.Manager = this;
            }

        }