Exemple #1
0
        /// <summary>
        /// Acquire a new Client object from the pool.
        /// </summary>
        /// <returns></returns>
        public static PooledClient Acquire()
        {
            if (poolSize < 1)
                throw new SDBPException(Status.SDBP_API_ERROR, "Uninitialized static class");

            PooledClient client;

            lock (clients)
            {
                if (clients.Count > 0)
                {
                    client = clients[0];
                    clients.RemoveAt(0);
                }
                else
                {
                    client = new PooledClient(controllers);
                }
            }
            return client;
        }
Exemple #2
0
        internal static void Release(PooledClient client)
        {
            if (poolSize < 1)
                throw new SDBPException(Status.SDBP_API_ERROR, "Uninitialized static class");

            lock (clients)
            {
                if (clients.Count < poolSize)
                    clients.Add(client);
            }
        }