Пример #1
0
 public void AddCommand(AtCmd cmd)
 {
     lock (cmd_table) {
         // do nothing if cmd's timeout is earlier than DateTime.Now
         if (cmd.Timeout < DateTime.Now)
             return;
         // insert at first if cmd's timeout is the earliest
         else if (cmd.Timeout < cmd_table.First().Timeout)
             cmd_table.Insert(0, cmd);
         // insert behind the one whose timeout is earlier than cmd's
         else {
             for (int i = cmd_table.Count - 1; i >= 0; i--) {
                 if (cmd_table[i].Timeout <= cmd.Timeout) {
                     cmd_table.Insert(i + 1, cmd);
                     break;
                 }
             }
         }
     }
 }
Пример #2
0
 public void DelCommand(AtCmd cmd)
 {
     lock (cmd_table) {
         cmd_table.Remove(cmd);
     }
 }