Beispiel #1
0
        public async Task <Telegram> ReadAsync()
        {
            try
            {
                if (_comm == null)
                {
                    _comm = new MyRcvTCPClient {
                        Name = _name, IP = _IP, Port = _port, TimeOut = _timeout, Version = _version
                    }
                }
                ;

                return(await _comm.Receive().ConfigureAwait(false));
            }
            catch (Exception ex)
            {
                try
                {
                    _comm.Close();
                }
                catch { }
                _comm = null;
                throw new FaultException(ex.Message);
            }
        }
Beispiel #2
0
        private bool disposedValue = false; // To detect redundant calls

        protected virtual void Dispose(bool disposing)
        {
            if (!disposedValue)
            {
                if (disposing)
                {
                    _comm?.Dispose();
                    _comm = null;
                }

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

                disposedValue = true;
            }
        }
Beispiel #3
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;
         _version = version;
         _comm    = new MyRcvTCPClient {
             Name = _name, IP = _IP, Port = _port, TimeOut = _timeout, Version = _version
         };
     }
     catch (Exception ex)
     {
         throw new FaultException(ex.Message);
     }
 }