Ejemplo n.º 1
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;
                }
            }
        }
Ejemplo n.º 2
0
        /// <inheritdoc/>
        protected override void OnStart(string[] args)
        {
            // Initialize the broker service cancellation token
            BrokerServiceTokenSource = new CancellationTokenSource();

            // Start the initial broker child process
            Broker.StartChildProcess();
        }