Exemple #1
0
 public Thread Listen(ICommandListener listener)
 {
     if (!_port.IsOpen)
     {
         _port.Open();
     }
     _listener   = listener;
     _readThread = new Thread(() =>
     {
         while (Thread.CurrentThread.IsAlive)
         {
             try
             {
                 var command = _port.ReadLine();
                 listener.Process(command);
             }
             catch (TimeoutException) {}
         }
     });
     _readThread.Start();
     return(_readThread);
 }