Beispiel #1
0
 public virtual void Close()
 {
     lock (DeviceLock) {
         IsClosing     = true;
         IsInterrupted = true;
     }
     Suspend();
     NotifyStateChange(ComponentState.Closing);
     if (WriteThread != null)
     {
         WriteThread.Task.Abort();
         WriteThread = null;
     }
     if (ReadThread != null)
     {
         ReadThread.Task.Abort();
         ReadThread = null;
     }
     if (ListenerThread != null)
     {
         ListenerThread.Task.Abort();
         ListenerThread = null;
     }
     // LinkManager.Manager.DeleteDevice(Id);
     DriverClose();
 }
Beispiel #2
0
 protected LinkDevice()
 {
     Interrupt       = new InterruptSource();
     IsClosing       = false;
     IsReading       = false;
     IsWriting       = false;
     IsInterrupted   = false;
     EnableListeners = true;
     ReadsCount      = 0;
     WritesCount     = 0;
     DeviceLock      = new Object();
     SuspendGate     = new Gate(true);
     WriteQueue      = new LinkedBlockingCollection <byte[]>();
     ReadQueue       = new BlockingCollection <byte[]>();
     ReadThread      = null;
     WriteThread     = null;
     ListenerThread  = null;
 }
Beispiel #3
0
 protected void InitThreads()
 {
     IsInterrupted = false;
     SuspendGate.SetState(true);
     if (EnableListeners && ListenerThread == null)
     {
         ListenerThread = new LinkDeviceListenerThread(this);
         ListenerThread.Start();
     }
     if (ReadThread == null)
     {
         ReadThread = new LinkDeviceReadThread(this);
         ReadThread.Start();
     }
     if (WriteThread == null)
     {
         WriteThread = new LinkDeviceWriteThread(this);
         WriteThread.Start();
     }
 }