コード例 #1
0
        public bool IsOnlyInstance()
        {
            bool isOnlyInstance;

            _mutex = new Mutex(true, _pipeName.ToString(), out isOnlyInstance);
            return(isOnlyInstance);
        }
コード例 #2
0
 public void TearDown()
 {
     if (Platform.OperatingSystem != OS.Mac)
     {
         return;
     }
     File.Delete(Path.Combine(UnixSocketStream.SocketDirectory, _pipeName.ToString()));
 }
コード例 #3
0
        /// <summary>
        ///     Connects to the named pipe
        /// </summary>
        /// <returns>Whether connection was successful</returns>
        public bool Connect()
        {
            Client = new NamedPipeClientStream(PipeName.ToString());

            var tries = 0;

            while (Client.IsConnected == false)
            {
                if (tries == 20)
                {
                    break;              // Failed to connect
                }
                Client.Connect();
                tries += 1;

                Thread.Sleep(1000);
            }

            return(Client.IsConnected);
        }