App.xaml.cs 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Configuration;
  4. using System.Data;
  5. using System.Linq;
  6. using System.Threading.Tasks;
  7. using System.Windows;
  8. using Microsoft.Shell;
  9. using MediaBrowser.Controller;
  10. namespace MediaBrowser.ServerApplication
  11. {
  12. /// <summary>
  13. /// Interaction logic for App.xaml
  14. /// </summary>
  15. public partial class App : Application, ISingleInstanceApp
  16. {
  17. private const string Unique = "MediaBrowser3";
  18. [STAThread]
  19. public static void Main()
  20. {
  21. if (SingleInstance<App>.InitializeAsFirstInstance(Unique))
  22. {
  23. var application = new App();
  24. application.InitializeComponent();
  25. application.Run();
  26. // Allow single instance code to perform cleanup operations
  27. SingleInstance<App>.Cleanup();
  28. }
  29. }
  30. #region ISingleInstanceApp Members
  31. public bool SignalExternalCommandLineArgs(IList<string> args)
  32. {
  33. // handle command line arguments of second instance
  34. // ...
  35. return true;
  36. }
  37. #endregion
  38. protected override void OnExit(ExitEventArgs e)
  39. {
  40. base.OnExit(e);
  41. Kernel.Instance.Dispose();
  42. }
  43. }
  44. }