示例#1
0
        public void Start(EventManager events = null)
        {
            if (events == null)
            {
                m_Events = new EventManager(m_path);
            }
            else
            {
                m_Events = events;
            }

            EventQueueClient.Enqueue(new StartEvent());

            m_Events.Start();
        }
示例#2
0
 public void Stop()
 {
     EventQueueClient.Enqueue(new StopEvent());
 }
示例#3
0
        public virtual Boolean Loop(Genie.Yuk.Event _event)
        {
            WinUtility        win   = Service.Resolve <WinUtility>();
            GameGraphics      gg    = Service.Resolve <GameGraphics>();
            CancellationToken token = Service.Resolve <CancellationToken>();

            if (_event != null)
            {
                if (_event.GetType() == typeof(StartEvent))
                {
                    Action myAction0 = (Action)(() =>
                    {
                        gg.Start();
                    });

                    Task taskA = Task.Run(myAction0);
                    taskA.Wait();

                    Action myAction1 = (Action)(() =>
                    {
                        while (!token.IsCancellationRequested)
                        {
                            gg.AlwaysRun();
                        }
                    });

                    win.OnUiThread(myAction1);

                    EventQueueClient.Enqueue(new GraphicsEvent());
                }
                else if (_event.GetType() == typeof(GraphicsEvent))
                {
                    lock (WriteServer.balanceLock)
                    {
                        ComponentManager.Update();
                        gg.Run(token);

                        System.Console.WriteLine("Draw Client");
                    }

                    EventQueueClient.Enqueue(new GraphicsEvent());
                }
                else if (_event.GetType() == typeof(JobEvent))
                {
                    JobEvent job = (JobEvent)_event;

                    Boolean doLoop = true;

                    while (doLoop)
                    {
                        try
                        {
                            Genie.Yuk.Event tmpEvent = job.Dequeue();
                            Loop(tmpEvent);
                        }
                        catch (InvalidOperationException e)
                        {
                            doLoop = false;
                        }
                    }
                }
                else if (_event.GetType() == typeof(StopEvent))
                {
                    System.Console.WriteLine("Stop");
                    return(false);
                }
            }

            return(true);
        }