ServiceRunner.cs 937 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. using Quartz;
  2. using Quartz.Impl;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Linq;
  6. using System.Text;
  7. using Topshelf;
  8. namespace TimedUpload
  9. {
  10. public class ServiceRunner : ServiceControl, ServiceSuspend
  11. {
  12. private readonly IScheduler scheduler;
  13. public ServiceRunner()
  14. {
  15. scheduler = StdSchedulerFactory.GetDefaultScheduler();
  16. }
  17. public bool Start(HostControl hostControl)
  18. {
  19. scheduler.Start();
  20. return true;
  21. }
  22. public bool Stop(HostControl hostControl)
  23. {
  24. scheduler.Shutdown(false);
  25. return true;
  26. }
  27. public bool Continue(HostControl hostControl)
  28. {
  29. scheduler.ResumeAll();
  30. return true;
  31. }
  32. public bool Pause(HostControl hostControl)
  33. {
  34. scheduler.PauseAll();
  35. return true;
  36. }
  37. }
  38. }