Guest User

Untitled

a guest
Jul 21st, 2018
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.52 KB | None | 0 0
  1. Parallel.ForEach(File.ReadLines(path), opt, a => { Fil(a); opt.CancellationToken.ThrowIfCancellationRequested(); });
  2.  
  3. using (FileStream fs = File.Open(accpath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
  4. {
  5. using (BufferedStream bs = new BufferedStream(fs))
  6. {
  7. using (StreamReader sr = new StreamReader(bs))
  8. {
  9. string line;
  10. while ((line = sr.ReadLine()) != null)
  11. {
  12. Fil(line);
  13. }
  14. }
  15. }
  16. }
  17.  
  18. void Fil(string txtresult)
  19. {
  20. try
  21. {
  22. mres.Wait();
  23.  
  24. string reg = @"w+([-+.]w+)*@w+([-.]w+)*.w+([-.]w+)*";
  25.  
  26. Regex regex = new Regex(reg);
  27. var dpl = txtresult.Split(' ');
  28. foreach (var m in dpl)
  29. {
  30. MatchCollection matches = regex.Matches(m);
  31. if (matches.Count > 0)
  32. {
  33. foreach (Match match in matches)
  34. {
  35. var matchh = Regex.Unescape(match.Value);
  36. var ss = m.Split('@')[1];
  37. var ch = ';';
  38. if (ss.Contains(":"))
  39. ch = ':';
  40. string pass = ss.Split(ch)[1];
  41. if (pass.Length > min && pass.Length < max)
  42. {
  43. // acs.Add(matchh + ch + pass);
  44. lock (lockerGood)
  45. {
  46. sw.WriteLine(matchh + ch + pass);
  47.  
  48. }
  49. }
  50.  
  51. }
  52. }
  53. }
  54.  
  55. }
  56. catch(Exception e)
  57. {
  58.  
  59.  
  60. lock (lockerErr)
  61. WriteToLog($"Ошбика в строке {txtresult}, текст ошибки {e.Message}");
  62. }
  63. }
  64.  
  65. foreach(var line in File.ReadLines(filePath))
  66. {
  67. Fil(line);
  68. }
  69.  
  70. Parallel.ForEach(File.ReadLines(path), opt, a => { Fil(a); opt.CancellationToken.ThrowIfCancellationRequested(); });
  71.  
  72. 1) Чтение с диска - медленная операция
  73. 2) Чем меньше чтений диска, тем лучше
  74. 3) Оперативная память не бесконечная
  75.  
  76. using(var bufferedFileStream =
  77. new BufferedStream(File.OpenRead(path), 1024*1024)) // буфер в мегабайт
  78. {
  79. ....
  80. }
  81.  
  82. using(var reader =
  83. new StreamReader(
  84. new BufferedStream(File.OpenRead(path), 1024*1024) // буфер в мегабайт
  85. ))
  86. {
  87. ....
  88. }
Add Comment
Please, Sign In to add comment