Ejemplo n.º 1
0
        /// <summary>
        /// 单个线程处理事务
        /// </summary>
        private void Process()
        {
            while (ContinueProcess)
            {
                Handler clientHandler = null;
                lock (Pool.SyncRoot)
                {
                    if (Pool.Count > 0)
                    {
                        clientHandler = Pool.Dequeue();
                    }
                }
                if (clientHandler != null)
                {
                    clientHandler.Process();                      // Provoke client
                    // if client still connect, schedufor later processingle it
                    if (clientHandler.Alive)
                    {
                        Pool.Enqueue(clientHandler);
                    }
                }

                Thread.Sleep(100);
            }
        }