Пример #1
0
        public void run()
        {
            Console.WriteLine("-=-=-=-=- Add 1 object -=-=-=-=-");
            q.Add(1);

            Console.WriteLine("-=-=-=-=- Peek 5sec -=-=-=-=-");
            Console.WriteLine("Peek: " + q.peek(5000));
            Console.WriteLine("-=-=-=-=- Remove 5sec -=-=-=-=-");
            Console.WriteLine("Remv: " + q.Remove(5000));
            Console.WriteLine("-=-=-=-=- Peek 5sec -=-=-=-=-");
            Console.WriteLine("Peek: " + q.peek(5000));
            Console.WriteLine("-=-=-=-=- Add 1 object -=-=-=-=-");
            q.Add(1);
            Console.WriteLine("-=-=-=-=- Remove 5sec -=-=-=-=-");
            Console.WriteLine("Remv: " + q.Remove(5000));
            Console.WriteLine("-=-=-=-=- Remove 5sec -=-=-=-=-");
            Console.WriteLine("Remv: " + q.Remove(5000));
            Console.WriteLine("-=-=-=-=- Close Queue -=-=-=-=-");
            q.close();
            Console.WriteLine("Closed?: " + q.Closed);

            try
            {
                Console.WriteLine("-=-=-=-=- Remove 5sec -=-=-=-=-");
                Console.WriteLine("Remv: " + q.Remove());
            }
            catch (Exception e)
            {
                Console.WriteLine("-=-=-=-=- Exception Thrown -=-=-=-=-");
                Console.WriteLine("Exception: " + e.Message);
            }
        }
Пример #2
0
        /// <summary>
        /// Removes the first received event.
        /// </summary>
        /// <param name="timeout">Time to wait on event arriving if all events have been delivered. Setting this less than 0 causes the method to wait indefinately on an event</param>
        /// <returns>First received event</returns>
        public override Event receive(int timeout)
        {
            Event evt;

            checkClosed();
            checkNotConnected();

            try
            {
                if (timeout < 0)
                {
                    evt = (Event)mq.Remove();
                }
                else
                {
                    evt = (Event)mq.Remove(timeout);
                }
                return(evt);
            }
            catch (QueueClosedException queue_closed)
            {
                throw new ChannelClosedException();
            }
            //catch(Exception e)
            //{
            //	if(Trace.trace)
            //		Trace.error("GroupChannel.receive()", "exception: " + e + "\n" + e.StackTrace);
            //	return null;
            //}
        }
Пример #3
0
        /// <summary>
        /// Thread to allow messages to be passed up asynchronously
        /// </summary>
        public void upHandler()
        {
            Event evt = null;

            while (true)
            {
                try
                {
                    evt = (Event)up_queue.Remove();
                    if (evt == null)
                    {
                        if (Trace.trace)
                        {
                            Trace.warn("Protocol [" + Name + "].UpHandler.run()", "removed null event");
                        }
                        continue;
                    }
                    up(evt);
                    evt = null;
                }
                catch (QueueClosedException queue_closed)
                {
                    break;
                }
                catch (Exception e)
                {
                    if (Trace.trace)
                    {
                        Trace.warn("Protocol [" + Name + "].UpHandler.run()", Name + " exception: " + e + "\n" + e.StackTrace);
                    }
                }
            }
        }
Пример #4
0
        public bool ProcessMoves()
        {
            var lastFrameNum = GameState.LastFrame;
            var thisFrameNum = GameState.GetFrame();

            if (thisFrameNum == lastFrameNum)
            {
                return(false);
            }

            AIProcess(thisFrameNum);

            if (thisFrameNum != lastFrameNum + 1 && thisFrameNum > lastFrameNum)
            {
                _log?.Invoke(null, new Logging.LogEventArgs($"Lost frames between { lastFrameNum } and { thisFrameNum }"));
            }

            Prev = State;
            if (MQueue.HasFrame(thisFrameNum))
            {
                State = MQueue.Get(thisFrameNum);
                var rem = MQueue.Remove(thisFrameNum);
                LogFrameState(thisFrameNum, State, rem);
            }
            else
            {
                State = new ControllerState(thisFrameNum);
            }
            return(true);
        }