Beispiel #1
0
 private bool Run()
 {
     lock (this)
     {
         if (_disposed)
         {
             return(false);
         }
         if (_mta != null)
         {
             return(false);
         }
         _mta = new Thread(() =>
         {
             while (!_disposed)
             {
                 LinkedListNode <Timer> n = _i++.Node;
                 do
                 {
                     if (n == null)
                     {
                         break;
                     }
                     Timer t = n.Value;
                     if (t == null || !t.Enabled)
                     {
                         break;
                     }
                     DateTime?lt = t.lasttime;
                     if (lt == null)
                     {
                         break;
                     }
                     TimeSpan ts = (DateTime.Now - lt.Value);
                     if (ts.TotalMilliseconds < t.Interval)
                     {
                         break;
                     }
                     t.lasttime = DateTime.Now;
                     t.DoTickEvent();
                 } while (false);
                 Waitable.usleep(25);
             }
         });
         _mta.IsBackground = true;
         _mta.Priority     = ThreadPriority.Lowest;
         _mta.Start();
         return(true);
     }
 }
Beispiel #2
0
 public static void usleep(int us)
 {
     Waitable.nanosleep(us * 10);
 }