/// <summary> /// После выполнения клиент не будет пытаться подключиться /// </summary> public void DisposeAsyncClient() { _isManualDispose = true; _asyncClient.Dispose(); _asyncClient = null; _isManualDispose = false; }
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); }
public void TearDown() { AsyncClient?.Dispose(); #if SYNC_CLIENT SyncClient?.Dispose(); #endif }
public virtual void TearDown() { AsyncClient?.Dispose(); #if SYNC_CLIENT SyncClient?.Dispose(); #endif CleanupEnvironmentVariables(); }
private void CleanUp(bool disposing) { if (!disposed && disposing) { Client.Dispose(); } disposed = true; }
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; }
/// <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; } }
private void ReConnect() { asyncClient.Dispose(); asyncClient.Connect(_ip, _port); }
private void ReConnect() { asyncClient.Dispose(); asyncClient.Connect(ConfigHelper.GetInstace().ZoneIP, ConfigHelper.GetInstace().ZonePort); }
public virtual void TearDown() { AsyncClient?.Dispose(); SyncClient?.Dispose(); CleanupEnvironmentVariables(); }