Esempio n. 1
0
        public void Update()
        {
            if (GamesStartInitialiseSystems.Count > 0)
            {
                var ToProcess = GamesStartInitialiseSystems[0];
                GamesStartInitialiseSystems.RemoveAt(0);
                var InInterface = ToProcess as IInitialise;
                if (InInterface == null)
                {
                    return;
                }
                InInterface.Initialise();
            }

            if (QueueInitialise.Count > 0)
            {
                //Logger.Log(QueueInitialise.Count.ToString() + " < in queue ");
                stopwatch.Reset();
                stopwatch.Start();
                Action QueueAction = null;
                while (stopwatch.ElapsedMilliseconds < TargetMSprefFrame)
                {
                    if (QueueInitialise.Count > 0)
                    {
                        QueueAction = QueueInitialise.Dequeue();
                        QueueAction.Invoke();
                    }
                    else
                    {
                        break;
                    }
                }

                stopwatch.Stop();
                //Logger.Log(stopwatch.ElapsedMilliseconds.ToString() + " < ElapsedMilliseconds ");
            }
            SpawnSafeThread.Process();
        }
Esempio n. 2
0
        public void Update()
        {
            if (GamesStartInitialiseSystems.Count > 0)
            {
                var ToProcess = GamesStartInitialiseSystems[0];
                GamesStartInitialiseSystems.RemoveAt(0);
                var InInterface = ToProcess as IInitialise;
                if (InInterface == null)
                {
                    return;
                }
                try
                {
                    InInterface.Initialise();
                }
                catch (Exception e)
                {
                    Logger.LogError(e.ToString());
                }
            }

            if (DelayedActions.Count > 0)
            {
                //Logger.Log(QueueInitialise.Count.ToString() + " < in queue ");
                stopwatch.Start();

                int i = 0;
                while (stopwatch.ElapsedMilliseconds < TargetMSprefFramePreStep && DelayedActions.Count > i)
                {
                    if (DelayedActions.Count > 0)
                    {
                        DelayedAction delayedAction = DelayedActions[i];
                        delayedAction.Frames -= 1;
                        if (delayedAction.Frames <= 0)
                        {
                            try
                            {
                                ToClear.Add(delayedAction);
                                delayedAction.Action.Invoke();
                            }
                            catch (Exception e)
                            {
                                Logger.LogError(e.ToString());
                            }
                        }

                        i++;
                    }
                    else
                    {
                        break;
                    }
                }

                stopwatch.Stop();
                stopwatch.Reset();
                //Logger.Log(stopwatch.ElapsedMilliseconds.ToString() + " < ElapsedMilliseconds ");
            }

            if (QueueInitialise.Count > 0)
            {
                //Logger.Log(QueueInitialise.Count.ToString() + " < in queue ");
                stopwatch.Start();
                Action QueueAction = null;
                while (stopwatch.ElapsedMilliseconds < TargetMSprefFramePreStep)
                {
                    if (QueueInitialise.Count > 0)
                    {
                        QueueAction = QueueInitialise.Dequeue();
                        try
                        {
                            QueueAction.Invoke();
                        }
                        catch (Exception e)
                        {
                            Logger.LogError(e.ToString());
                        }
                    }
                    else
                    {
                        break;
                    }
                }

                stopwatch.Stop();
                stopwatch.Reset();
                //Logger.Log(stopwatch.ElapsedMilliseconds.ToString() + " < ElapsedMilliseconds ");
            }

            foreach (var delayedAction in ToClear)
            {
                DelayedActions.Remove(delayedAction);
            }

            SpawnSafeThread.Process();
        }