ContiguousWorker.cs 1.0 KB

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