コード例 #1
0
 public void close()
 {
     if (serial == null)
     {
         return;
     }
     connected = false;
     lock (nextlineLock)
     {
         try
         {
             serial.Close();
             serial.Dispose();
         }
         catch (Exception) { }
         serial = null;
     }
     job.KillJob();
     history.Clear();
     injectCommands.Clear();
     resendNode = null;
     if (eventConnectionChange != null)
     {
         try
         {
             Main.main.Invoke(eventConnectionChange, "Disconnected");
         }
         catch { } // Closing the app can cause an exception, if event comes after Main handle is destroyed
     }
     firePrinterAction("Idle");
     Main.main.Invoke(Main.main.UpdateJobButtons);
 }
コード例 #2
0
 public void close()
 {
     if (serial == null)
     {
         return;
     }
     if (job.mode == 1)
     {
         job.KillJob();
     }
     Application.DoEvents();
     Thread.Sleep(100);
     Application.DoEvents();
     connected = false;
     if (readThread != null)
     {
         readThread.Abort();
     }
     readThread = null;
     //  lock (nextlineLock)
     // {
     try
     {
         serial.Close();
         serial.Dispose();
     }
     catch (Exception) { }
     serial = null;
     // }
     job.KillJob();
     history.Clear();
     injectCommands.Clear();
     resendNode        = null;
     comErrorsReceived = 0;
     if (eventConnectionChange != null)
     {
         try
         {
             Main.main.Invoke(eventConnectionChange, "Disconnected");
         }
         catch { } // Closing the app can cause an exception, if event comes after Main handle is destroyed
     }
     firePrinterAction("Idle");
     Main.main.Invoke(Main.main.UpdateJobButtons);
 }