BackgroundService.cs 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. using MediaBrowser.Model.Logging;
  2. using System.ServiceProcess;
  3. namespace MediaBrowser.ServerApplication
  4. {
  5. /// <summary>
  6. /// Class BackgroundService
  7. /// </summary>
  8. public class BackgroundService : ServiceBase
  9. {
  10. public static string Name = "MediaBrowser";
  11. public static string DisplayName = "Media Browser";
  12. private readonly ILogger _logger;
  13. /// <summary>
  14. /// Initializes a new instance of the <see cref="BackgroundService"/> class.
  15. /// </summary>
  16. public BackgroundService(ILogger logger)
  17. {
  18. _logger = logger;
  19. CanPauseAndContinue = false;
  20. CanStop = true;
  21. ServiceName = Name;
  22. }
  23. /// <summary>
  24. /// When implemented in a derived class, executes when a Stop command is sent to the service by the Service Control Manager (SCM). Specifies actions to take when a service stops running.
  25. /// </summary>
  26. protected override void OnStop()
  27. {
  28. _logger.Info("Stop command received");
  29. base.OnStop();
  30. }
  31. }
  32. }