private void                button_Disconnect_Click(object aSender, EventArgs aEventArgs)
 {
     try
     {
         mConnectionS7PLCSim.disconnect();
     }
     catch (Exception lExc)
     {
         Log.Error("Error while user was disconnecting from Siemens S7-PLCSIM. " + lExc.Message, lExc.ToString());
         MessageForm.showMessage(lExc.Message, this);
     }
 }
 public IConnection createByForm(IWin32Window aOwner)
 {
     Connection lConnection = new Connection();
         using (var lSetupForm = new ConnectionSetupForm(lConnection, true))
         {
             if (lSetupForm.ShowDialog(aOwner) == DialogResult.Cancel)
             {
                 if (lConnection.Connected)
                 {
                     lConnection.disconnect();
                 }
                 lConnection.Dispose();
                 lConnection = null;
             }
         }
         return lConnection;
 }
        public IConnection  createByForm(IWin32Window aOwner)
        {
            Connection lConnection = new Connection();

            using (var lSetupForm = new ConnectionSetupForm(lConnection, true))
            {
                if (lSetupForm.ShowDialog(aOwner) == DialogResult.Cancel)
                {
                    if (lConnection.Connected)
                    {
                        lConnection.disconnect();
                    }
                    lConnection.Dispose();
                    lConnection = null;
                }
            }
            return(lConnection);
        }