diff options
| author | Luke Pulverenti <luke.pulverenti@gmail.com> | 2013-09-20 21:04:14 -0400 |
|---|---|---|
| committer | Luke Pulverenti <luke.pulverenti@gmail.com> | 2013-09-20 21:04:14 -0400 |
| commit | 2e511fba839e86d9393e5eeb10795f1b0aed7ce0 (patch) | |
| tree | d82481b8352ae2f088cbe902cc7fc222b8b0a0ed /MediaBrowser.ServerApplication/BackgroundService.cs | |
| parent | b5615cb233923f8424a40af009101a901f30f591 (diff) | |
support run as service
Diffstat (limited to 'MediaBrowser.ServerApplication/BackgroundService.cs')
| -rw-r--r-- | MediaBrowser.ServerApplication/BackgroundService.cs | 40 |
1 files changed, 25 insertions, 15 deletions
diff --git a/MediaBrowser.ServerApplication/BackgroundService.cs b/MediaBrowser.ServerApplication/BackgroundService.cs index a8a9a5b50..019a11e1c 100644 --- a/MediaBrowser.ServerApplication/BackgroundService.cs +++ b/MediaBrowser.ServerApplication/BackgroundService.cs @@ -1,30 +1,40 @@ -using System.ServiceProcess; +using MediaBrowser.Model.Logging; +using System.ServiceProcess; namespace MediaBrowser.ServerApplication { + /// <summary> + /// Class BackgroundService + /// </summary> public class BackgroundService : ServiceBase { - public BackgroundService() + public static string Name = "MediaBrowser"; + public static string DisplayName = "Media Browser"; + + private readonly ILogger _logger; + + /// <summary> + /// Initializes a new instance of the <see cref="BackgroundService"/> class. + /// </summary> + public BackgroundService(ILogger logger) { + _logger = logger; + CanPauseAndContinue = false; - CanHandleSessionChangeEvent = true; - CanStop = false; - CanShutdown = true; - ServiceName = "Media Browser"; - } - protected override void OnSessionChange(SessionChangeDescription changeDescription) - { - base.OnSessionChange(changeDescription); - } + CanStop = true; - protected override void OnStart(string[] args) - { + ServiceName = Name; } - protected override void OnShutdown() + /// <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() { - base.OnShutdown(); + _logger.Info("Stop command received"); + + base.OnStop(); } } } |
