Ejemplo n.º 1
0
        /// <summary>
        /// 分发消息 异步 会在协程BeginHandleReceiveMessageQueue的下一次检查种真正的消息分发
        /// </summary>
        /// <param name="iMessageType"></param>
        /// <param name="kParam"></param>
        public void DispatchMessageAsync(uint iMessageType, object kParam)
        {
            lock (_receiveMessageQueue)
            {
                MessageArgs args = new MessageArgs()
                {
                    iMessageType = iMessageType,
                    kParam       = kParam,
                };

                _receiveMessageQueue.Enqueue(args);
            }
        }
Ejemplo n.º 2
0
        private IEnumerator BeginHandleReceiveMessageQueue()
        {
            while (true)
            {
                yield return(0);

                lock (_receiveMessageQueue)
                {
                    while (_receiveMessageQueue.Count != 0)
                    {
                        MessageArgs args = _receiveMessageQueue.Dequeue();
                        DispatchMessage(args.iMessageType, args.kParam);
                    }
                }
            }
        }