Guest User

Untitled

a guest
Dec 14th, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.37 KB | None | 0 0
  1. if(flow.CheckEngineCapacity >= 2000 || (Convert.ToInt32(totalRows) - numberOfRecords) < 2000)
  2. {
  3. waitHandle.Set();
  4. Thread fileProcessor = new Thread(delegate () { flow.ProcessExportEngineFlow(waitHandle); });
  5. fileProcessor.Start();
  6. }
  7.  
  8. public class EngineFlow
  9. {
  10. private static ConcurrentQueue<WebPages> _concurrentWebPageList = new ConcurrentQueue<WebPages>();
  11.  
  12. public bool IncreaseEngineFlow(WebPages page)
  13. {
  14. bool sucessfullyadded = false;
  15. if (_concurrentWebPageList.Count <= 2000)
  16. {
  17. _concurrentWebPageList.Enqueue(page);
  18. }
  19. else
  20. {
  21. return sucessfullyadded;
  22. }
  23. return sucessfullyadded;
  24. }
  25.  
  26. public int CheckEngineCapacity { get { return _concurrentWebPageList.Count; } }
  27.  
  28. private WebPages DecreaseEngineFlow()
  29. {
  30. WebPages page;
  31. _concurrentWebPageList.TryDequeue(out page);
  32. return page;
  33. }
  34.  
  35. public void ProcessExportEngineFlow(AutoResetEvent waitHandle)
  36. {
  37. if (waitHandle.WaitOne() == false)
  38. {
  39. Thread.Sleep(100);
  40. }
  41. else
  42. {
  43. while (!_concurrentWebPageList.IsEmpty)
  44. {
  45. Console.WriteLine(DecreaseEngineFlow().URL);
  46. Console.WriteLine(CheckEngineCapacity);
  47. waitHandle.Set();
  48. }
  49. }
  50. }
Add Comment
Please, Sign In to add comment