Exemple #1
0
        public void Tick()
        {
            try
            {
                ScriptContext.GlobalCleanUp();

                var delays = ms_delays.ToArray();
                var now    = DateTime.Now;

                foreach (var delay in delays)
                {
                    if (now >= delay.Item1)
                    {
                        delay.Item2(new DummyAsyncResult());

                        ms_delays.Remove(delay);
                    }
                }

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

                CitizenTaskScheduler.Instance.Tick();
                CitizenSynchronizationContext.Tick();
            }
            catch (Exception e)
            {
                Debug.WriteLine("Error during Tick: {0}", e.ToString());

                throw;
            }
        }
Exemple #2
0
        public void Tick()
        {
            if (GameInterface.SnapshotStackBoundary(out var b))
            {
                ScriptHost.SubmitBoundaryStart(b, b.Length);
            }

            try
            {
                ScriptContext.GlobalCleanUp();

                var delays = ms_delays.ToArray();
                var now    = DateTime.UtcNow;

                foreach (var delay in delays)
                {
                    if (now >= delay.Item1)
                    {
                        delay.Item2(new DummyAsyncResult());

                        ms_delays.Remove(delay);
                    }
                }

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

                CitizenTaskScheduler.Instance.Tick();
                CitizenSynchronizationContext.Tick();
            }
            catch (Exception e)
            {
                PrintError("tick", e);
            }
            finally
            {
                ScriptHost.SubmitBoundaryStart(null, 0);
            }
        }
Exemple #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 delays = ms_delays.ToArray();
                    var now    = DateTime.UtcNow;

                    foreach (var delay in delays)
                    {
                        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.Remove(delay);
                        }
                    }
                }

                using (var scope = new ProfilerScope(() => "c# schedule"))
                {
                    foreach (var script in ms_definedScripts.ToArray())
                    {
                        script.ScheduleRun();
                    }
                }

                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);
            }
        }