예제 #1
0
            /// <summary>
            /// Compara a instancias.
            /// </summary>
            /// <param name="x"></param>
            /// <param name="y"></param>
            /// <returns></returns>
            public int Compare(object x, object y)
            {
                QueuedEvent event2 = x as QueuedEvent;
                QueuedEvent event3 = y as QueuedEvent;

                return(event2.SchedTime.CompareTo(event3.SchedTime));
            }
예제 #2
0
 /// <summary>
 /// Método de execução.
 /// </summary>
 private void Run()
 {
     try
     {
         Task          task;
         TimeScheduler scheduler;
         while (true)
         {
             Monitor.Enter(scheduler = this);
             try
             {
                 if (_thread == null)
                 {
                     return;
                 }
             }
             finally
             {
                 Monitor.Exit(scheduler);
             }
             lock (_queue)
             {
                 long elapsedTime;
                 if (_queue.IsEmpty)
                 {
                     Monitor.Wait(_queue, (int)_suspendInterval);
                 }
                 if (_queue.IsEmpty)
                 {
                     InternalSuspend();
                     return;
                 }
                 QueuedEvent o = _queue.Peek();
                 lock (o)
                 {
                     task = o.Task;
                     if (task.IsCancelled())
                     {
                         _queue.Pop();
                         continue;
                     }
                     elapsedTime = o.ElapsedTime;
                     if (elapsedTime >= o.Interval)
                     {
                         _queue.Pop();
                         if (o.ReQueue())
                         {
                             _queue.Push(o);
                         }
                     }
                 }
                 if (elapsedTime < o.Interval)
                 {
                     Monitor.Wait(_queue, (int)(o.Interval - elapsedTime));
                     continue;
                 }
             }
             try
             {
                 task.Run();
             }
             catch (Exception exception)
             {
                 Colosoft.Logging.Trace.Error("TimeScheduler._run()".GetFormatter(), exception.GetFormatter());
             }
         }
     }
     catch (ThreadInterruptedException exception2)
     {
         Colosoft.Logging.Trace.Error("TimeScheduler._run()".GetFormatter(), exception2.GetFormatter());
     }
 }