解决方案 »

  1.   

    用线程池啊~~
    ThreadPool.SetMaxThreads(10, 10);
    for (int i = 0; i < 10000; i++)
    {
        ThreadPool.QueueUserWorkItem((obj) =>
        {
            MessageBox.Show("Do Some thing");
        });
    }
      

  2.   


    这种程序就是一句话
    Quote:
    var result = (from x in MyUrls.AsParallel()
              select Proc(x))
              .Count();
      

  3.   


    SetMaxThreads() 并不起作用,而且如果起作用反而会去干涉了其它事情的计算,得不偿失。而且这种程序没有完成基本的“流程控制”,也就是没有表明如何做到“采集函数执行完后,统一返回结果”的要求。
      

  4.   

    如果你的并行度是10,应该这样设置:http://msdn.microsoft.com/zh-cn/library/dd383719(v=vs.100).aspx
      

  5.   

    string[] urls = new string[10000];
                Parallel.For(0, 10, (i) =>
                {
                    for (int j = 0; j < 1000; j++)
                    {
                        string url = urls[j + i * 1000];
                        //HttpWebRequest
                        //Else
                    }
                });
                //Finished