Exemplo n.º 1
0
 /// <summary>
 /// Fire the Pool Refilled event if assigned
 /// </summary>
 /// <param name="pea"></param>
 protected void OnPoolRefilled(PoolRefilledEventArgs pea)
 {
     if (PoolRefilled != null)
     {
         PoolRefilled(this, pea);
     }
 }
Exemplo n.º 2
0
        /// <summary>
        /// The method that is called asynchronously to refill the proxy pool.
        /// </summary>
        /// <param name="state">Optional state to pass onto the repopulation method. Currently unused - reserved for future use.</param>
        private void RepopulateProxyPoolAction(object state)
        {
            int  oldPoolCount         = _channelList.Count;
            int  oldProxiesToAddCount = 0;
            bool poolFilled           = false;

            while (_runRefillThread)
            {
                if (Config.PoolSize - _channelList.Count >= _poolRefillTrigger)
                {
                    oldProxiesToAddCount = Config.PoolSize - _channelList.Count;

                    RefillPool();
                    poolFilled = true;
                }

                if (poolFilled)
                {
                    // Fire the event
                    PoolRefilledEventArgs pea = new PoolRefilledEventArgs();
                    pea.PoolCountBeforeAdd = oldPoolCount;
                    pea.ProxiesAddedToPool = oldProxiesToAddCount;
                    OnPoolRefilled(pea);
                    poolFilled = false;
                }

                oldPoolCount = _channelList.Count;
            }

            DebugMessage("...exiting refill thread loop.");
        }