コード例 #1
0
        private void Run()
        {
            BeforeRun?.Invoke(this, new EventArgs());
            int lastTick    = Environment.TickCount;
            int firstTick   = lastTick;
            int currentTick = 0;

            working = true;

            while (working)
            {
                currentTick = Environment.TickCount;
                cntrLogic.Tick();
                TickEventArgs args = new TickEventArgs(new Time(TimeSpan.FromMilliseconds(Environment.TickCount - firstTick), TimeSpan.FromMilliseconds(currentTick - lastTick)), cntrLogic);
                LogicTick?.Invoke(this, args);
                DrawTick?.Invoke(this, args);

                if (args.Stop)
                {
                    break;
                }

                lastTick = Environment.TickCount;

                if (this.LimitFrames)
                {
                    long passed = lastTick - currentTick + 1;
                    if (passed <= timePerTick)
                    {
                        Thread.Sleep((int)(timePerTick - passed));
                    }
                }
            }
            AfterRun?.Invoke(this, new EventArgs());
        }
コード例 #2
0
 private void OnBeforeRun(string text) => BeforeRun?.Invoke(this, CreateArgs(text));
コード例 #3
0
 /// <summary>
 /// Invokes <see cref="BeforeRun"/> event (don't forget to call base.OnBeforeRun in override)
 /// </summary>
 /// <param name="serviceProvider"><see cref="IServiceProvider"/> to be passed in event args</param>
 protected virtual void OnBeforeRun(IServiceProvider serviceProvider)
 {
     BeforeRun?.Invoke(this, new ServiceProviderEventArgs(serviceProvider));
 }
コード例 #4
0
 private void OnBeforeRun(List <Code> codes)
 {
     BeforeRun?.Invoke(this, codes);
 }