Пример #1
0
        /// <summary>
        /// Listen abort queue for abort message untill render is finished.
        /// </summary>
        /// <param name="suffix">Suffix of abort queue name</param>
        private void startWaitingProcess(string suffix)
        {
            //create Queue for abort message
            try
            {
                m_abortQueue = new MessageQueue <RenderMessage>(suffix);
            }
            catch (Exception e)
            {
                m_log.Error("Error creating queue: " + e.Message);
                abort();
            }
            RenderMessage rendMessage = m_abortQueue.WaitForMessage(typeof(ToAbortRenderMessage), roleIsFinish);

            if (rendMessage != null)
            {
                m_log.Info("message type: " + rendMessage.GetType().Name);
                m_log.Info("Abort message");
                abort();
            }
        }
Пример #2
0
        public override void Run()
        {
            try
            {
                Trace.TraceInformation("Listening for queue messages...");
                m_log.Info("Worker is started.\nListening for queue messages...");
                MessageQueue <RenderMessage> localQueue = null;
                while (true)
                {
                    //check if worker is allocated and ready to work
                    RenderMessage rendMes = m_renderHandler.WaitForMessage(typeof(IsFreeMessage));
                    m_log.Info("IsFreeMessage");
                    IsFreeMessage isFreeMessage = rendMes as IsFreeMessage;
                    MessageQueue <DispetcherMessage> dispHandler = new MessageQueue <DispetcherMessage>(isFreeMessage.SceneId.ToString()); //create queue to dispatcher thread
                    localQueue = new MessageQueue <RenderMessage>(isFreeMessage.SceneId.ToString());
                    m_log.Info("sending 'I am ready' message");
                    dispHandler.AddMessage(new WorkerIsReady(isFreeMessage.SessionId)); //signal to dispatcher: "Ready to work!"
                    m_aborted = false;
                    m_log.Info("/IsFreeMessage");

                    rendMes = localQueue.WaitForMessage(typeof(ToRenderMessage));
                    m_log.Info("Got messege: " + rendMes.GetType().Name);
                    m_log.Info("ToRenderMessage start");
                    ToRenderMessage message = rendMes as ToRenderMessage;
                    initializeRender(message);
                    startRender();
                    m_log.Info("Abort queue name suffix: " + message.AbortQueueSuffix);
                    startWaitingProcess(message.AbortQueueSuffix);
                    renderFinished();
                    m_log.Info("/ToRenderMessage");
                }
            }
            catch (Exception e)
            {
                interruptRender(e.Message);
            }
        }