多线程处理

        int nMaxThreadNum = 5;
        List<List<JobParam>> jobQueue = new List<List<JobParam>>();
        //...
        for (int i = 0; i < nMaxThreadNum;i++)
        {
            ThreadPool.QueueUserWorkItem(new WaitCallback(AsyncDoRetrieve), jobQueue&#91;i&#93;);
        }

        static void AsyncDoRetrieve(object state)
        {
            if (!(state == null && state is List<JobParam>)) return;
            List<JobParam> jobParams= state as List<JobParam> ;
            foreach(JobParam param in jobParams)
            {
                param.delegateDoSomeThing.BeginInvoke(param,null,null);
            }
        }

Comments are closed.