Example #1
0
		/// <remarks>
		/// <b>Relative Scheduling</b>
		/// <tt>true</tt>:<br></br>
		/// Task is rescheduled relative to the last time it <i>actually</i>
		/// started execution
		///	<p>
		/// <tt>false</tt>:<br></br>
		/// Task is scheduled relative to its <i>last</i> execution schedule. This
		/// has the effect that the time between two consecutive executions of
		/// the task remains the same.
		/// </p>
		/// </remarks>
		/// <summary>
		/// Add a task for execution at adjustable intervals
		/// </summary>
		/// <param name="t">The task to execute</param>
		/// <param name="relative">Use relative scheduling</param>
		public void AddTask(Task t, bool relative) 
		{
			long interval;
			lock(this) 
			{
				if(thread_state == State.DISPOSED) return;
				if((interval = t.GetNextInterval()) < 0) return;

                queue.Push(new QueuedEvent(t));

				switch(thread_state) 
				{
					case State.RUN: break; 
					case State.SUSPEND: _unsuspend(); break;
					case State.STOPPING: break;
					case State.STOP: break;
				}
			}
		}