Пример #1
0
 public void Dispose()
 {
     lock (this)
     {
         if (timer != null)
         {
             timer.Dispose();
         }
         group.SendResetRequest();
         reader.OnError -= this.reader_OnClose;
         reader.Dispose();
         if (_conditionList != null)
         {
             foreach (var condition in _conditionList)
             {
                 if (condition != null)
                 {
                     condition.AlarmActive -= cond_SendAlarm;
                 }
             }
         }
         reval.Dispose();
     }
 }
Пример #2
0
        private void DisconnectForced(string reason)
        {
            bool clientWasConnected = Client?.Connected == true;

            ReceivedLines.Clear();
            Client?.Dispose();
            ClientStream?.Dispose();
            ClientReader?.Dispose();
            ClientWriter?.Dispose();

            Client       = null;
            ClientStream = null;
            ClientReader = null;
            ClientWriter = null;

            Connected     = false;
            ReadLoopTask  = null;
            KeepAliveTask = null;

            if (clientWasConnected)
            {
                ConnectionClosed?.Invoke(this, new EventArgs <string>(reason));
            }
        }