Exemple #1
0
        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;
                    }
                }
            }
        }
Exemple #2
0
        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);
        }
        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)
        {
            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 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;
		}