Ejemplo n.º 1
0
 /// <summary>
 /// Create a new listener.
 /// </summary>
 /// <param name="task">The task that is listening.</param>
 public TaskListener(ThreadedTask task)
 {
     m_task = task;
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Wait on task to finish before running.
        /// This task will be added to the scheduler waiting queue
        /// and will be added to the schedule queue when all tasks
        /// it is waiting on have finished.
        /// </summary>
        public virtual void WaitOn(ThreadedTask task)
        {
            lock(m_lock)
            {
                if (task.Cancelled)
                    throw new InvalidOperationException("Can not wait on a task that is cancelled");

                if (task.Done)
                    throw new InvalidOperationException("Can not wait on a task that is already done");

                if(task.IsThreaded && task.NoFinish && !m_isThreaded)
                    throw new InvalidOperationException("A non-threaded task cant wait on a threaded task with no finish");

                m_listener.Waiting++;
                task.Listeners.AddLast(m_listener);
            }
        }