C#Parallel.Invoke:操作被取消异常?

时间:2015-11-18 11:55:08

标签: multithreading c#-4.0

嗨,

以下代码工作正常但有时我得到操作被取消异常

 var _options = new ParallelOptions();
    _options.MaxDegreeOfParallelism = 5;
    Parallel.Invoke(_options, 
        () =>
            {
                //get list of item1 
                foreach (var item in lst_item1)
                {
                    // do some logic here
                }
            },
        () =>
        {
            //get list of item1 
            foreach (var item in lst_item2)
            {
                // do some logic here
            }
        },
          () =>
          {
        //get list of item1 
        foreach (var item in lst_item2)
        {
           // do some logic here
        }
    });
// continue logic code

非常感谢任何帮助!

此致

0 个答案:

没有答案
相关问题