Beispiel #1
0
        /// <summary>
        /// Checks for messages from workers and processes any queued items.
        /// </summary>
        private void checkMessages()
        {
            List <WorkerRegistration> regPool = workerRegistrationPool.GetRegistrationPool();

            lock (regPool)
            {
                foreach (WorkerRegistration wr in regPool)
                {
                    try
                    {
                        if (wr.ClientServer == null)
                        {
                            // Do nothing, client is still in registration phase.
                        }
                        else if (wr.ClientServer.MessageIsAvailable())
                        {
                            workerMessageProcessor.ProcessMessage(wr, wr.ClientServer.ReceiveObject <string>());
                        }
                    }
                    catch (IOException e)
                    {
                        SharedLogger.Error("Manager", "Worker Registration Service", "A network error occurred while receiving a network message from a worker");
                        SharedLogger.ErrorStackTrace("Manager", "Worker Registration Service", new Exception($"Error checking for messages from worker '{wr.Name}'.", e));
                    }
                }
            }
        }