public void ClearAllPools() { lock (this.SyncObject) { if (this.pools != null) { lock (this.pools.SyncRoot) { FbConnectionPool[] tempPools = new FbConnectionPool[this.pools.Count]; this.pools.Values.CopyTo(tempPools, 0); foreach (FbConnectionPool pool in tempPools) { // Clear pool pool.Clear(); } // Clear Hashtables this.pools.Clear(); this.handlers.Clear(); } } } }
private void OnEmptyPool(object sender, EventArgs e) { lock (this.Pools.SyncRoot) { int hashCode = (int)sender; if (this.pools.ContainsKey(hashCode)) { FbConnectionPool pool = (FbConnectionPool)this.Pools[hashCode]; lock (pool.SyncObject) { EmptyPoolEventHandler handler = (EmptyPoolEventHandler)this.Handlers[hashCode]; pool.EmptyPool -= handler; this.Pools.Remove(hashCode); this.Handlers.Remove(hashCode); pool = null; handler = null; } } } }
private void OnEmptyPool(object sender, EventArgs e) { lock (this.Pools.SyncRoot) { string connectionString = (string)sender; if (this.Pools.ContainsKey(connectionString)) { FbConnectionPool pool = (FbConnectionPool)this.Pools[connectionString]; lock (pool.SyncObject) { EmptyPoolEventHandler handler = (EmptyPoolEventHandler)this.Handlers[connectionString]; pool.EmptyPool -= handler; this.Pools.Remove(connectionString); this.Handlers.Remove(connectionString); pool = null; handler = null; } } } }
public FbConnectionPool CreatePool(string connectionString) { FbConnectionPool pool = null; lock (this.SyncObject) { pool = this.FindPool(connectionString); if (pool == null) { lock (this.pools.SyncRoot) { int hashcode = connectionString.GetHashCode(); // Create an empty pool handler EmptyPoolEventHandler handler = new EmptyPoolEventHandler(this.OnEmptyPool); this.Handlers.Add(hashcode, handler); // Create the new connection pool pool = new FbConnectionPool(connectionString); this.pools.Add(hashcode, pool); pool.EmptyPool += handler; } } } return(pool); }
public FbConnectionPool GetPool(string connectionString) { FbConnectionPool pool = this.FindPool(connectionString); if (pool == null) { pool = this.CreatePool(connectionString); } return(pool); }
public FbConnectionPool FindPool(string connectionString) { FbConnectionPool pool = null; lock (this.SyncObject) { if (this.Pools.ContainsKey(connectionString)) { pool = (FbConnectionPool)this.Pools[connectionString]; } } return(pool); }
public FbConnectionPool FindPool(string connectionString) { FbConnectionPool pool = null; lock (this.SyncObject) { int hashCode = connectionString.GetHashCode(); if (this.Pools.ContainsKey(hashCode)) { pool = (FbConnectionPool)pools[hashCode]; } } return(pool); }
public void ClearPool(string connectionString) { lock (this.SyncObject) { lock (this.Pools.SyncRoot) { if (this.Pools.ContainsKey(connectionString)) { FbConnectionPool pool = (FbConnectionPool)this.Pools[connectionString]; // Clear pool pool.Clear(); } } } }
private void CleanupWorker(object state) { FbConnectionPool pool = state as FbConnectionPool; pool.Cleanup(); if (pool.Count == 0) { lock (pool.SyncObject) { // Empty pool if (pool.EmptyPool != null) { pool.EmptyPool(pool.connectionString, null); } } pool.cleanupTimer.Dispose(); } }
public void ClearPool(string connectionString) { lock (this.SyncObject) { if (this.pools != null) { lock (this.pools.SyncRoot) { int hashCode = connectionString.GetHashCode(); if (this.pools.ContainsKey(hashCode)) { FbConnectionPool pool = (FbConnectionPool)this.pools[hashCode]; // Clear pool pool.Clear(); } } } } }
public void ClearAllPools() { lock (this.SyncObject) { lock (this.Pools.SyncRoot) { FbConnectionPool[] tempPools = new FbConnectionPool[this.Pools.Count]; this.Pools.Values.CopyTo(tempPools, 0); foreach (FbConnectionPool pool in tempPools) { // Clear pool pool.Clear(); } // Clear Hashtables this.Pools.Clear(); this.Handlers.Clear(); } } }
public FbConnectionPool CreatePool(string connectionString) { lock (this.SyncObject) { FbConnectionPool pool = this.FindPool(connectionString); if (pool == null) { lock (this.Pools.SyncRoot) { // Create an empty pool handler EmptyPoolEventHandler handler = new EmptyPoolEventHandler(this.OnEmptyPool); // Create the new connection pool pool = new FbConnectionPool(connectionString); this.Handlers.Add(connectionString, handler); this.Pools.Add(connectionString, pool); pool.EmptyPool += handler; } } return pool; } }
public int GetPooledConnectionCount(string connectionString) { FbConnectionPool pool = this.FindPool(connectionString); return((pool != null) ? pool.Count : 0); }