public void AddTask(IScheduledITask t)
        {
            lock (tasks) {
                int n;
                for (n = 0; n < tasks.Count; n++)
                {
                    if (t.DueTime < tasks [n].DueTime)
                    {
                        break;
                    }
                }
                tasks.Insert(n, t);
                if (n == 0)
                {
                    newTask.Set();
                }

                if (scheduler == null)
                {
                    scheduler = new ST.Thread(SchedulerThread);
                    scheduler.IsBackground = true;
                    scheduler.Start();
                }
            }
        }
 public void Shutdown(object owner, bool continueExistingPeriodicTasks, bool executeExistingDelayedTasks)
 {
     if (!executeExistingDelayedTasks)
     {
         lock (tasks) {
             for (int n = 0; n < tasks.Count; n++)
             {
                 IScheduledITask t = tasks [n];
                 if (t.Owner == owner)
                 {
                     tasks.RemoveAt(n);
                     n--;
                 }
             }
             newTask.Set();
         }
     }
 }