コード例 #1
0
        /// <summary>
        /// 创建线程池
        /// </summary>
        /// <param name="maxThreadCount"></param>
        /// <returns></returns>
        public QYThreadPool CreateThreadPool(int maxThreadCount)
        {
            QYThreadPool threadPool = new QYThreadPool(this, maxThreadCount);

            this.threadPoolList.Add(threadPool);
            return(threadPool);
        }
コード例 #2
0
        /// <summary>
        /// 执行工作
        /// </summary>
        public void DoWork()
        {
            for (;;)
            {
                //等待一个消息
                autoEvent.WaitOne();

                for (int i = 0; i < this.threadPoolList.Count; i++)
                {
                    QYThreadPool threadPool = this.threadPoolList[i];
                    if (!threadPool.isFullLoad) //如果这个线程还未满负载
                    {
                        threadPool.DoWork();    //让线程执行工作
                    }
                }
            }
        }