aboutsummaryrefslogtreecommitdiff
path: root/Emby.Server.Implementations/EntryPoints/SystemEvents.cs
blob: 72c8acd9f0e1d30931e8f2729715e63a8833a457 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
using System;
using MediaBrowser.Controller;
using MediaBrowser.Controller.Plugins;
using MediaBrowser.Model.System;

namespace Emby.Server.Implementations.EntryPoints
{
    public class SystemEvents : IServerEntryPoint
    {
        private readonly ISystemEvents _systemEvents;
        private readonly IServerApplicationHost _appHost;

        public SystemEvents(ISystemEvents systemEvents, IServerApplicationHost appHost)
        {
            _systemEvents = systemEvents;
            _appHost = appHost;
        }

        public void Run()
        {
            _systemEvents.SystemShutdown += _systemEvents_SystemShutdown;
        }

        private void _systemEvents_SystemShutdown(object sender, EventArgs e)
        {
            _appHost.Shutdown();
        }

        public void Dispose()
        {
            _systemEvents.SystemShutdown -= _systemEvents_SystemShutdown;
        }
    }
}