Ejemplo n.º 1
0
        private bool disposedValue = false; // To detect redundant calls

        protected virtual void Dispose(bool disposing)
        {
            if (!disposedValue)
            {
                if (disposing)
                {
                    // TODO: dispose managed state (managed objects).
                }

                _comm?.Dispose();
                _comm = null;
                // TODO: free unmanaged resources (unmanaged objects) and override a finalizer below.
                // TODO: set large fields to null.

                disposedValue = true;
            }
        }
Ejemplo n.º 2
0
 public void Init(string name, string addr, int SendPort, int timeoutSec, string version)
 {
     try
     {
         _IP      = IPAddress.Parse(addr);
         _port    = SendPort;
         _timeout = TimeSpan.FromSeconds(timeoutSec);
         _name    = name;
         _comm    = new MySendTCPClient {
             Name = _name, IP = _IP, Port = _port, TimeOut = _timeout
         };
     }
     catch (Exception ex)
     {
         throw new FaultException(ex.Message);
     }
 }
Ejemplo n.º 3
0
 public async Task <Telegram> SendAsync(Telegram t)
 {
     try
     {
         if (_comm == null)
         {
             _comm = new MySendTCPClient {
                 Name = _name, IP = _IP, Port = _port, TimeOut = _timeout
             }
         }
         ;
         return(await _comm.Send(t).ConfigureAwait(false));
     }
     catch (Exception ex)
     {
         try
         {
             _comm.Close();
         }
         catch { }
         _comm = null;
         throw new FaultException(ex.Message);
     }
 }