Abdalla Omran

Abdalla Omran

  • NA
  • 334
  • 29.5k

Parallel.ForEach (is there any thing more faster) ?!

Jan 2 2020 7:48 AM
In this method reading a big data from a text file it's lines about milionen and it takes between 6 until 7 min to read and filter that . so is there anyway to make it more faster ? 
  1. private static List<WebShopDataAccess> GetWebShopDataAccesses(string path)  
  2.         {  
  3.              List<WebShopDataAccess> elements = new List<WebShopDataAccess>();  
  4.   
  5.             List<string> lines = File.ReadAllLines(path).ToList();  
  6.             var filterIPs = lines.Where(x => x.Contains("google")).ToList();  
  7.   
  8.  Parallel.ForEach(filterIPs, line =>  
  9.             {  
  10.   
  11. // do some staff   
  12. });  
  13.   
  14. return elements;  
  15.         }  
 

Answers (3)