Пример #1
0
        /// <summary>
        /// This method is run by the calling thread of Run so as not to interupt the
        /// message processing pump.
        /// </summary>
        /// <param name="msg"></param>
        private void DoDispatchMessage(IMessage msg)
        {
            if (msg.Type == Enums.SystemPacketType.CarType)
            {
                CarMessageHandler.Invoke(msg);
            }
            else if (msg.Type == Enums.SystemPacketType.ControlType)
            {
                if (ControlMessageHandler != null)
                {
                    ControlMessageHandler.Invoke(msg);
                }
            }
            else
            {
                if (msg is EndOfSession)
                {
                    // Tell the thread to stop blocking and exit after it's processed the remainder of messages.
                    Stop(JoinMethod.DontJoin, false);
                }

                if (msg is EventId)
                {
                    CurrentEventType = (msg as EventId).EventType;
                }

                SystemMessageHandler.Invoke(msg);
            }
        }
        /// <summary>
        /// This method is run by the calling thread of Run so as not to interupt the
        /// message processing pump.
        /// </summary>
        /// <param name="msg"></param>
        private void DoDispatchMessage(IMessage msg)
        {
            if (msg.Type == Enums.SystemPacketType.CarType)
            {
                CarMessageHandler.Invoke(msg);
            }
            else if (msg.Type == Enums.SystemPacketType.ControlType)
            {
                ControlMessageHandler.Invoke(msg);
            }
            else
            {
                if (msg is EndOfSession)
                {
                    // Tell the thread to stop blocking and exit after it's processed the remainder of messages.
                    Stop(JoinMethod.DontJoin, false);
                }

                if (msg is EventId)
                {
                    CurrentEventType = (msg as EventId).EventType;
                }

                SystemMessageHandler.Invoke(msg);
            }
        }