aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.ServerApplication/App.xaml.cs
diff options
context:
space:
mode:
Diffstat (limited to 'MediaBrowser.ServerApplication/App.xaml.cs')
-rw-r--r--MediaBrowser.ServerApplication/App.xaml.cs57
1 files changed, 32 insertions, 25 deletions
diff --git a/MediaBrowser.ServerApplication/App.xaml.cs b/MediaBrowser.ServerApplication/App.xaml.cs
index db229905d..41fb8f24e 100644
--- a/MediaBrowser.ServerApplication/App.xaml.cs
+++ b/MediaBrowser.ServerApplication/App.xaml.cs
@@ -1,50 +1,57 @@
-using System;
+using MediaBrowser.Common.Kernel;
+using MediaBrowser.Common.UI;
+using MediaBrowser.Controller;
+using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Windows;
-using MediaBrowser.Common.Kernel;
-using MediaBrowser.Common.UI;
-using MediaBrowser.Controller;
-using Microsoft.Shell;
namespace MediaBrowser.ServerApplication
{
/// <summary>
/// Interaction logic for App.xaml
/// </summary>
- public partial class App : BaseApplication, ISingleInstanceApp
+ public partial class App : BaseApplication, IApplication
{
- private const string Unique = "MediaBrowser3";
-
[STAThread]
public static void Main()
{
- if (SingleInstance<App>.InitializeAsFirstInstance(Unique))
- {
- var application = new App();
- application.InitializeComponent();
+ RunApplication<App>("MediaBrowserServer");
+ }
- application.Run();
+ protected override void OnSecondInstanceLaunched(IList<string> args)
+ {
+ base.OnSecondInstanceLaunched(args);
- // Allow single instance code to perform cleanup operations
- SingleInstance<App>.Cleanup();
- }
+ OpenDashboard();
+ InitializeComponent();
+ }
+
+ public static void OpenDashboard()
+ {
+ OpenUrl("http://localhost:" + Kernel.Instance.Configuration.HttpServerPortNumber + "/mediabrowser/dashboard/index.html");
}
- #region ISingleInstanceApp Members
- public bool SignalExternalCommandLineArgs(IList<string> args)
+ public static void OpenUrl(string url)
{
- OpenDashboard();
+ var process = new Process
+ {
+ StartInfo = new ProcessStartInfo
+ {
+ FileName = url
+ },
- return true;
+ EnableRaisingEvents = true
+ };
+
+ process.Exited += ProcessExited;
+
+ process.Start();
}
- #endregion
- public static void OpenDashboard()
+ static void ProcessExited(object sender, EventArgs e)
{
- using (Process process = Process.Start("http://localhost:" + Kernel.Instance.Configuration.HttpServerPortNumber + "/mediabrowser/dashboard/index.html"))
- {
- }
+ (sender as Process).Dispose();
}
protected override IKernel InstantiateKernel()