using Newtonsoft.Json; using System; using System.Linq; using System.Text.RegularExpressions; using System.Threading; using System.Windows; using ZetaIpc.Runtime.Client; namespace Tango.FSE.LogViewer.UI { /// /// Interaction logic for App.xaml /// public partial class App : Application { private static Mutex mutex = new Mutex(true, "{8F6F0AC4-B9A1-45fd-A8CF-TANGLOGVIEWR}"); public const int FILE_ASSPCIATION_PORT = 8989; protected override void OnStartup(StartupEventArgs e) { if (e.Args != null && e.Args.Length > 0) { if (mutex.WaitOne(TimeSpan.Zero, true)) { //This is the first instance. Do nothing... mutex.ReleaseMutex(); } else { var ipcClient = new IpcClient(); ipcClient.Initialize(FILE_ASSPCIATION_PORT); ipcClient.Send(JsonConvert.SerializeObject(new ArgsObject() { Args = e.Args.ToList() })); Thread.Sleep(1000); Environment.Exit(0); return; } } base.OnStartup(e); } } }