Example #1
0
        private static void SendData(string args)
        {
            NamedPipeManager clientPipe = new NamedPipeManager();

            if (clientPipe.Write(args))
            {
                Environment.Exit(0);
            }
        }
Example #2
0
        /// <summary>
        /// Checks a mutex to see if an instance is running and decides how to proceed based on this and args
        /// </summary>
        /// <param name="args"></param>
        public static void InstanceCheck(string[] args)
        {
            Func <string[], bool> ArgCheck = a => a != null && a.Length > 0 && File.Exists(a[0]);
            bool isOnlyInstance            = false;

            if (ArgCheck(args) || args.Length == 0)
            {
                mutex = new Mutex(true, "WDBXEditorMutex", out isOnlyInstance);
                if (!isOnlyInstance)
                {
                    Program.PrimaryInstance = false;
                    SendData(args); //Send args to the primary instance
                }
                else
                {
                    Program.PrimaryInstance = true;
                    pipeServer = new NamedPipeManager();
                    pipeServer.ReceiveString += OpenRequest;
                    pipeServer.StartServer();
                }
            }
        }