/// <summary>
 /// Listener thread, in which we continue looping until the app terminates or IsActive is false.
 /// </summary>
 private void ListenerThread()
 {
     while (IsActive)
     {
         IPCHandlers.HandleIncomingMessage(ReadFromPipe(), this);
     }
 }
Beispiel #2
0
        /// <summary>
        /// Broker listener thread, in which we continue listening for messages from the client until the app terminates or a cancellation has been requested.
        /// </summary>
        public void BrokerListenerThread()
        {
            // Wait for a client to connect to the broker pipe
            try
            {
                if (WaitForConnectionAsyncWrapper().Result)
                {
                    Broker.StartChildProcess();
                }
            }
            catch (Exception e)
            {
                ErrorHandling.ErrorHandler.Handle(e, ErrorHandling.LogLevel.Debug);
                return;
            }

            // Handle incoming messages from the pipe while it is connected
            while (!BrokerService.BrokerServiceTokenSource.IsCancellationRequested && pipe.IsConnected)
            {
                try
                {
                    IPCHandlers.HandleIncomingMessage(ReadFromPipe(pipe, readAsync: true), this);
                }
                catch (Exception e)
                {
                    ErrorHandling.ErrorHandler.Handle(e, ErrorHandling.LogLevel.Debug);
                    break;
                }
            }
        }
Beispiel #3
0
        /// <summary>
        /// Stops all spawned child processes and exits the broker service.
        /// </summary>
        public static void StopAllChildProcesses()
        {
            BrokerService.BrokerServiceTokenSource.Cancel();
            IPCHandlers.SignalServiceQueue();

            // Wait until all child processes have quit, but honor the broker service timeout
            Task.WaitAll(ChildProcessList.ToArray(), BrokerServiceTimeout);
        }
Beispiel #4
0
        /// <summary>
        /// Client listener thread, in which we continue listening for message from the broker until the app terminates or a cancellation has been requested.
        /// </summary>
        private void ClientListenerThread()
        {
            while (true)
            {
                if (!pipe.IsConnected)
                {
                    try
                    {
                        ((NamedPipeClientStream)pipe).Connect();
                    }
                    catch (Exception e)
                    {
                        ErrorHandling.ErrorHandler.Handle(e, ErrorHandling.LogLevel.Error);
                        continue;
                    }
                }

                IPCHandlers.HandleIncomingMessage(ReadFromPipe(pipe), this);
            }
        }