BlockingQueue.cs 764 B

1234567891011121314151617181920212223242526272829303132333435
  1. using System;
  2. using System.Collections.Concurrent;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7. namespace parkMonitor.tools
  8. {
  9. public class BlockingQueue
  10. {
  11. private BlockingCollection<object> bQueue = new BlockingCollection<object>(new ConcurrentQueue<object>());
  12. public void Enqueue(object message)
  13. {
  14. bQueue.Add(message);
  15. }
  16. public object Dequeue()
  17. {
  18. //if(count() != 0)
  19. //{
  20. return bQueue.Take();
  21. //}
  22. //else
  23. //{
  24. // return null;
  25. //}
  26. }
  27. public int count()
  28. {
  29. return bQueue.Count();
  30. }
  31. }
  32. }