Ejemplo n.º 1
0
        public static void Tick()
        {
            var flowBlock = CitizenTaskScheduler.SuppressFlow();

            Action[] tasks;

            lock (m_scheduledTasks)
            {
                tasks = m_scheduledTasks.ToArray();
                m_scheduledTasks.Clear();
            }

            foreach (var task in tasks)
            {
                try
                {
                    task();
                }
                catch (Exception e)
                {
                    Debug.WriteLine($"Exception during executing Post callback: {e}");
                }
            }

            flowBlock?.Undo();
        }
Ejemplo n.º 2
0
        public static void Tick()
        {
            var flowBlock = CitizenTaskScheduler.SuppressFlow();

            try
            {
                Action[] tasks;

                lock (m_scheduledTasks)
                {
                    tasks = m_scheduledTasks.ToArray();
                    m_scheduledTasks.Clear();
                }

                foreach (var task in tasks)
                {
                    try
                    {
                        task();
                    }
                    catch (Exception e)
                    {
                        InternalManager.PrintErrorInternal($"task continuation", e);
                    }
                }
            }
            finally
            {
            }

            flowBlock?.Undo();
        }
Ejemplo n.º 3
0
        public void Tick()
        {
            IsProfiling = ProfilerIsRecording();

            if (GameInterface.SnapshotStackBoundary(out var b))
            {
                ScriptHost.SubmitBoundaryStart(b, b.Length);
            }

            try
            {
                using (var scope = new ProfilerScope(() => "c# cleanup"))
                {
                    ScriptContext.GlobalCleanUp();
                }

                using (var scope = new ProfilerScope(() => "c# deferredDelay"))
                {
                    var now   = DateTime.UtcNow;
                    var count = ms_delays.Count;

                    for (int delayIdx = 0; delayIdx < count; delayIdx++)
                    {
                        var delay = ms_delays[delayIdx];

                        if (now >= delay.Item1)
                        {
                            using (var inScope = new ProfilerScope(() => delay.Item3))
                            {
                                try
                                {
                                    BaseScript.CurrentName = delay.Item3;
                                    delay.Item2(new DummyAsyncResult());
                                }
                                finally
                                {
                                    BaseScript.CurrentName = null;
                                }
                            }

                            ms_delays.RemoveAt(delayIdx);
                            delayIdx--;
                            count--;
                        }
                    }
                }

                using (var scope = new ProfilerScope(() => "c# schedule"))
                {
                    var flowBlock = CitizenTaskScheduler.SuppressFlow();

                    foreach (var script in ms_definedScripts.ToArray())
                    {
                        script.ScheduleRun();
                    }

                    flowBlock?.Undo();
                }

                using (var scope = new ProfilerScope(() => "c# tasks"))
                {
                    CitizenTaskScheduler.Instance.Tick();
                }

                using (var scope = new ProfilerScope(() => "c# syncCtx"))
                {
                    CitizenSynchronizationContext.Tick();
                }
            }
            catch (Exception e)
            {
                PrintError("tick", e);
            }
            finally
            {
                ScriptHost.SubmitBoundaryStart(null, 0);
            }
        }