jellyfin/MediaBrowser.ServerApplication/BackgroundService.cs

46 lines
1.2 KiB
C#
Raw Normal View History

2013-09-21 01:04:14 +00:00
using MediaBrowser.Model.Logging;
using System.ServiceProcess;
namespace MediaBrowser.ServerApplication
{
2013-09-21 01:04:14 +00:00
/// <summary>
/// Class BackgroundService
/// </summary>
public class BackgroundService : ServiceBase
{
2015-05-23 20:44:15 +00:00
public static string Name = "Emby";
public static string DisplayName = "Emby Server";
public static string GetExistingServiceName()
{
return Name;
}
2013-09-21 01:04:14 +00:00
private readonly ILogger _logger;
/// <summary>
/// Initializes a new instance of the <see cref="BackgroundService"/> class.
/// </summary>
public BackgroundService(ILogger logger)
{
2013-09-21 01:04:14 +00:00
_logger = logger;
CanPauseAndContinue = false;
2013-09-21 01:04:14 +00:00
CanStop = true;
2015-05-23 20:44:15 +00:00
ServiceName = GetExistingServiceName();
}
2013-09-21 01:04:14 +00:00
/// <summary>
/// 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.
/// </summary>
protected override void OnStop()
{
2013-09-21 01:04:14 +00:00
_logger.Info("Stop command received");
base.OnStop();
}
}
}