ContinousWorker.cs 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. using System;
  2. using System.Threading.Tasks;
  3. using Quadarax.Foundation.Core.Logging;
  4. namespace Quadarax.Foundation.Core.Thread
  5. {
  6. public class ContinousWorker : AbstractWorker
  7. {
  8. #region *** Private fields ***
  9. private Action _body;
  10. #endregion
  11. #region *** Properties ***
  12. #endregion
  13. #region *** Constructors ***
  14. public ContinousWorker(Action body = null, IWorkerContext context = null) : base(context)
  15. {
  16. _body = body;
  17. }
  18. public ContinousWorker(string workerName, ILogger logger = null) : base(workerName,null, logger)
  19. {
  20. }
  21. public ContinousWorker(string workerName, IWorkerContext context, ILogger logger = null) : base(workerName,context , logger)
  22. {
  23. }
  24. #endregion
  25. #region *** Public Operations ***
  26. #endregion
  27. #region *** Virtuals and protected ***
  28. protected override async Task Do(IWorkerContext context)
  29. {
  30. _body?.Invoke();
  31. }
  32. #endregion
  33. #region *** Private Operations ***
  34. #endregion
  35. }
  36. }