Beispiel #1
0
 /// <summary>
 /// После выполнения клиент не будет пытаться подключиться
 /// </summary>
 public void DisposeAsyncClient()
 {
     _isManualDispose = true;
     _asyncClient.Dispose();
     _asyncClient     = null;
     _isManualDispose = false;
 }
Beispiel #2
0
        private AsyncClient RegenerateClient(string host, int port, List <string> secondaryHosts)
        {
            AsyncClient existing  = null;
            var         clientKey = GetClientKey(host, port, secondaryHosts);

            _lock.EnterWriteLock();
            try
            {
                AsyncClient client = null;
                if (_cachedClientDictionary.TryGetValue(clientKey, out existing) == false)
                {
                    client = GetNewClient(host, port, secondaryHosts);
                    _cachedClientDictionary[clientKey] = client;
                    return(client);
                }
                if (existing.Connected == false)
                {
                    existing.Dispose();
                    _cachedClientDictionary.Remove(clientKey);

                    client = GetNewClient(host, port, secondaryHosts);
                    _cachedClientDictionary[clientKey] = client;
                    return(client);
                }
            }
            finally
            {
                _lock.ExitWriteLock();
            }
            return(existing);
        }
Beispiel #3
0
        public void TearDown()
        {
            AsyncClient?.Dispose();
#if SYNC_CLIENT
            SyncClient?.Dispose();
#endif
        }
Beispiel #4
0
        public virtual void TearDown()
        {
            AsyncClient?.Dispose();
#if SYNC_CLIENT
            SyncClient?.Dispose();
#endif
            CleanupEnvironmentVariables();
        }
Beispiel #5
0
 private void CleanUp(bool disposing)
 {
     if (!disposed && disposing)
     {
         Client.Dispose();
     }
     disposed = true;
 }
Beispiel #6
0
 private void btnStop_Click(object sender, EventArgs e)
 {
     try
     {
         _Client.Close();
         _Client.Dispose();
         _Client = null;
     }
     catch { }
     SetControlEnabled(btnStart, true);
     SetControlEnabled(btnStop, false);
 }
        /// <summary>
        ///     Release resources back to the operating system.
        /// </summary>
        /// <param name="disposing"></param>
        protected virtual void Dispose(bool disposing)
        {
            if (_disposed)
            {
                return;
            }

            if (disposing)
            {
                _asyncClient.Dispose();
            }

            _disposed = true;
        }
Beispiel #8
0
 /// <summary>釋放 TcpMaster 所使用的資源。 </summary>
 /// <param name="disposing">是否完全釋放</param>
 protected virtual void Dispose(bool disposing)
 {
     if (disposing)
     {
         _OnDisposing = true;
         if (_Client != null)
         {
             try
             {
                 _Client.Close();
                 _Client.Dispose();
             }
             finally
             {
                 _Client = null;
             }
         }
         this.IsDisposed = true;
     }
 }
Beispiel #9
0
 private void ReConnect()
 {
     asyncClient.Dispose();
     asyncClient.Connect(_ip, _port);
 }
Beispiel #10
0
 private void ReConnect()
 {
     asyncClient.Dispose();
     asyncClient.Connect(ConfigHelper.GetInstace().ZoneIP, ConfigHelper.GetInstace().ZonePort);
 }
Beispiel #11
0
 public virtual void TearDown()
 {
     AsyncClient?.Dispose();
     SyncClient?.Dispose();
     CleanupEnvironmentVariables();
 }