コード例 #1
0
 public override bool StartAsyncAcceptingClients()
 {
     keep_modbus_server_alive = true;
     try {
         ClientManagmentThread.Start();
     } catch (Exception e) {
         if ((e is ThreadStateException) || (e is OutOfMemoryException))
         {
             return(false);
         }
         else
         {
             throw e;
         }                  // Unexpected exception
     }
     return(true);
 }
コード例 #2
0
 public override bool RequestStopAsyncAcceptingClientsAndJoin()
 {
     keep_modbus_server_alive = false;
     try {
         ClientManagmentThread.Join();
     } catch (Exception e) {
         if ((e is ThreadStateException) || (e is ThreadStartException))
         {
             Console.WriteLine(e);
             return(false);
         }
         else
         {
             throw e;
         }                  // Unexpected exception
     }
     return(true);
 }
コード例 #3
0
 public override bool StartAsyncAcceptingClients()
 {
     MCU.StartAsyncAcceptingClients();
     keep_modbus_server_alive = true;
     try {
         ClientManagmentThread.Start();
     } catch (Exception e) {
         if ((e is ThreadStateException) || (e is OutOfMemoryException))
         {
             logger.Error(Utilities.GetTimeStamp() + ": failed to start prodi=uction plc and mcu threads err:____    {0}", e);
             return(false);
         }
         else
         {
             throw e;
         }                  // Unexpected exception
     }
     return(true);
 }
コード例 #4
0
 public override bool RequestStopAsyncAcceptingClientsAndJoin()
 {
     MCU.RequestStopAsyncAcceptingClientsAndJoin();
     keep_modbus_server_alive = false;
     try
     {
         PLC_Modbusserver.Dispose();
         PLCTCPListener.Stop();
         ClientManagmentThread.Join();
     } catch (Exception e) {
         if ((e is ThreadStateException) || (e is ThreadStartException))
         {
             logger.Error(e);
             return(false);
         }
         else
         {
             throw e;
         }                  // Unexpected exception
     }
     return(true);
 }