Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if(flow.CheckEngineCapacity >= 2000 || (Convert.ToInt32(totalRows) - numberOfRecords) < 2000)
- {
- waitHandle.Set();
- Thread fileProcessor = new Thread(delegate () { flow.ProcessExportEngineFlow(waitHandle); });
- fileProcessor.Start();
- }
- public class EngineFlow
- {
- private static ConcurrentQueue<WebPages> _concurrentWebPageList = new ConcurrentQueue<WebPages>();
- public bool IncreaseEngineFlow(WebPages page)
- {
- bool sucessfullyadded = false;
- if (_concurrentWebPageList.Count <= 2000)
- {
- _concurrentWebPageList.Enqueue(page);
- }
- else
- {
- return sucessfullyadded;
- }
- return sucessfullyadded;
- }
- public int CheckEngineCapacity { get { return _concurrentWebPageList.Count; } }
- private WebPages DecreaseEngineFlow()
- {
- WebPages page;
- _concurrentWebPageList.TryDequeue(out page);
- return page;
- }
- public void ProcessExportEngineFlow(AutoResetEvent waitHandle)
- {
- if (waitHandle.WaitOne() == false)
- {
- Thread.Sleep(100);
- }
- else
- {
- while (!_concurrentWebPageList.IsEmpty)
- {
- Console.WriteLine(DecreaseEngineFlow().URL);
- Console.WriteLine(CheckEngineCapacity);
- waitHandle.Set();
- }
- }
- }
Add Comment
Please, Sign In to add comment