mohit ranjan

mohit ranjan

  • NA
  • 51
  • 0

How to Increase Parallel for Each Loop in C#

Sep 9 2013 8:47 AM
 List<string> aa = new List<string>();
            aa.Add("aa");                           
            int count = 0;
            Parallel.ForEach(aa, new ParallelOptions { MaxDegreeOfParallelism = 1 }, bb =>
            {                      
                Console.WriteLine("value:" + bb);                                  
                    aa.Add("asasasa");               
                Thread.Sleep(10);                            
            }
            );

Here only one loop of parallel.foreach run but i have added value in list "aa"  so it should go to infinite loop but it is not behaving like that