SystemEvents.cs 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using MediaBrowser.Model.System;
  7. using MediaBrowser.Controller.Plugins;
  8. using MediaBrowser.Common;
  9. using MediaBrowser.Controller;
  10. namespace Emby.Server.Implementations.EntryPoints
  11. {
  12. public class SystemEvents : IServerEntryPoint
  13. {
  14. private readonly ISystemEvents _systemEvents;
  15. private readonly IServerApplicationHost _appHost;
  16. public SystemEvents(ISystemEvents systemEvents, IServerApplicationHost appHost)
  17. {
  18. _systemEvents = systemEvents;
  19. _appHost = appHost;
  20. }
  21. public void Run()
  22. {
  23. _systemEvents.SystemShutdown += _systemEvents_SystemShutdown;
  24. }
  25. private void _systemEvents_SystemShutdown(object sender, EventArgs e)
  26. {
  27. _appHost.Shutdown();
  28. }
  29. public void Dispose()
  30. {
  31. _systemEvents.SystemShutdown -= _systemEvents_SystemShutdown;
  32. }
  33. }
  34. }