예제 #1
0
 public Timer(DateTime dateTime, string formatting = DefaultFormat)
 {
     format  = formatting;
     expires = dateTime;
     OnTick?.Invoke((expires - DateTime.UtcNow).ToString(format));
     Manager.OnTick += Tick;
 }
예제 #2
0
 void IPlayable.Stop()
 {
     _timer.Stop();
     Stop();
     Source = null;
     OnTick?.Invoke(this, new PlayerEventArgs(PercentProgress, Duration, Position));
 }
예제 #3
0
 /// <summary>
 /// Used to run in a loop. Invokes the OnTick event
 /// </summary>
 public void Tick()
 {
     if (CanTick())
     {
         OnTick?.Invoke();
     }
 }
예제 #4
0
        protected override void ThreadTick()
        {
            ProcessNewlyConnectedClients();
            ProcessNewlyDisconnectedClients();

            // Grab all incoming packets and push them to the players
            ProcessAllIncomingPackets();

            OnTick?.Invoke();

            if (gatewaySocket != null && hasConnectedToGateway == true)
            {
                FlushAllOutgoingPackets();
            }
            else
            {
                ClearAllOutgoingPackets();
                ConnectToGateway();
            }

            profileServer.Tick();

            frameId++;
            var milliSec = startTime.ElapsedMilliseconds;

            if (milliSec - snapShotTime > 1000)
            {
                snapShotTime = milliSec;
#if DEBUG_FRAMES
                Console.Write("frame# {0}, ms elapsed {1}, ms per frame {2}\n", frameId, milliSec, (float)milliSec / (float)frameId);
#endif
            }
            SendFrameTickToAllConnectedClients();
        }
예제 #5
0
 internal static void Tick()
 {
     if (OnTick != null)
     {
         OnTick.Invoke();
     }
 }
예제 #6
0
 private void InvokeOnTick()
 {
     if (OnTick != null)
     {
         OnTick.Invoke();
     }
 }
예제 #7
0
    public void Tick(float time)
    {
        if (IsProgramPaused)
        {
            return;
        }

        if (!IsDone && !IsPaused)
        {
            //Debug.Log(ElapsedTime + " -- " + Time + " -- " + Callback);
            ElapsedTime += time;
            IsDone       = ElapsedTime >= Time;

            if (IsDone)
            {
                ElapsedTime = Time;
                //Debug.Log("CALLING CALLBACK");
                Callback?.Invoke();
            }
            else
            {
                OnTick?.Invoke(this);
            }
        }
        else
        {
        }
    }
예제 #8
0
 public void HandleTick(object sender, ElapsedEventArgs args)
 {
     foreach (var trader in _traders)
     {
         try
         {
             if (trader.PanicCondition)
             {
                 trader.Panic();
             }
         }
         catch (Exception ex)
         {
             Log.Warn(ex.Message);
         }
     }
     try
     {
         OnTick?.Invoke(sender, args);
     }
     catch (Exception ex)
     {
         Log.Warn(ex.Message);
     }
 }
        private void handleImageGrabbed(object sender, EventArgs args)
        {
            PreTick();

            try
            {
                Mat = new Mat();

                if (Capture.Retrieve(Mat))
                {
                    if (Mat.IsEmpty)
                    {
                        return;
                    }

                    using (var vector = new VectorOfByte())
                    {
                        CvInvoke.Imencode(getStringfromEncodingFormat(format), Mat, vector, encodingParams?.ToArray());
                        data = vector.ToArray();
                    }
                }

                OnTick?.Invoke();
            }
            catch (CvException e)
            {
                logger.Add($@"{e.Status} {e.Message}", osu.Framework.Logging.LogLevel.Verbose, e);
            }
        }
예제 #10
0
        public void Update()
        {
            Application.DoEvents();
            OnTick?.Invoke();

            GameForm.Update();
        }
예제 #11
0
파일: GameTick.cs 프로젝트: MexBanDoc/game
 public static void Tick(GameModel gameModel)
 {
     if (gameModel.IsRunning)
     {
         OnTick.Invoke(gameModel);
     }
 }
예제 #12
0
        /// <summary>
        /// Called when a physics tick occurs.
        /// </summary>
        /// <param name="world"></param>
        /// <param name="timeStep"></param>
        public void PhysicsTick(DynamicsWorld world, float timeStep)
        {
            int framesPassed = BPhysicsWorld.Get().frameCount - lastFrameCount;

            OnTick.Invoke(world, timeStep, framesPassed);
            lastFrameCount += framesPassed;
        }
예제 #13
0
        public void StartLoop()
        {
            lastFrame = glfw.GetTimerValue();
            long step = 0;

            while (!glfw.WindowShouldClose(window))
            {
                glfw.PollEvents();
                currentFrame = glfw.GetTimerValue();
                deltaTime    = (currentFrame - lastFrame) / glfw.GetTimerFrequency();
                lastFrame    = currentFrame;

                //Console.WriteLine($"FPS: {1f / deltaTime}");
                if (deltaTime > (1f / 30f))
                {
                    deltaTime = 1f / 30f;
                }

                if (OnTick == null)
                {
                    break;
                }
                OnTick.Invoke(new Time(deltaTime, glfw.GetTime(), step));
                step++;
            }

            glfw.Terminate();
        }
예제 #14
0
 /// <summary>
 /// Internal tick process
 /// </summary>
 private void _TickThreadProc()
 {
     while (true)
     {
         OnTick?.Invoke();
         Sleep(Interval);
     }
 }
예제 #15
0
 private void Tick(object o)
 {
     if (Interlocked.CompareExchange(ref timerBusy, 1, 0) == 0)
     {
         OnTick?.Invoke();
         timerBusy = 0;
     }
 }
예제 #16
0
        private static IEnumerator Tick()
        {
            for (; IsRunning;)
            {
                yield return(new WaitForSeconds(0.25f));

                OnTick?.Invoke();
            }
        }
예제 #17
0
 public void Tick()
 {
     TimePayed++;
     OnTick?.Invoke(this);
     if (TimePayed == TimeCost && !_isCompleted)
     {
         CompleteResearch();
     }
 }
예제 #18
0
    private void SetTimePassedThisMonth(float _timePassedThisMonth)
    {
        if (_timePassedThisMonth >= 0 && timePassedThisMonth != _timePassedThisMonth)
        {
            timePassedThisMonth = _timePassedThisMonth;

            OnTick?.Invoke();
        }
    }
예제 #19
0
 public void TickUp(float speed)
 {
     if (value >= maxValue && !IsZeroOrBelow)
     {
         return;
     }
     value += Time.deltaTime * speed;
     OnTick?.Invoke(value / maxValue);
 }
 private void DispatcherTimer_Tick(object sender, EventArgs e)
 {
     OnTick?.Invoke();
     foreach (var student in Students.Where(x => x.RemoteId != null))
     {
         //if(Students.Any(x => OnTick == x.UpTime))
         InitializeRating(student.RemoteId);
     }
 }
예제 #21
0
 public Timer()
 {
     new System.Timers.Timer {
         Interval = 1000
     }.Elapsed += (sender, args) =>
     {
         OnTick?.Invoke(this, new TimeEventArgs(args.SignalTime));
     };
 }
예제 #22
0
 private void Count()
 {
     while (true)
     {
         Thread.Sleep(intInterval);
         AddPoints();
         OnTick?.Invoke(points);
     }
 }
예제 #23
0
        public void Tick(int time)
        {
            _deliveryTasks.ForEach(deliveryTask => deliveryTask.Setup());
            _deliveryTasks.RemoveAll(deliveryTask => deliveryTask.IsCompleted);

            OnTick?.Invoke(time);

            _deliveryTasks.ForEach(deliveryTask => deliveryTask.Setup(time));
            _deliveryTasks.RemoveAll(deliveryTask => deliveryTask.IsCompleted);
        }
        private void HandleTicking()
        {
            if (_mainMusicSource.time < _tickTime)
            {
                return;
            }

            _tickTime = currentConfiguration.GetNextTickTime();
            OnTick?.Invoke();
        }
예제 #25
0
 private void T_Tick(object sender, EventArgs e)
 {
     _loopNo++;
     OnTick?.Invoke(this);
     if (_loopNo >= LoopCount)
     {
         T.Stop();
         OnFinished?.Invoke(this);
     }
 }
예제 #26
0
        /// <summary>
        /// Called by PlayerLoopSystem before each update
        /// </summary>
        void Tick()
        {
#if UNITY_EDITOR
            if (!Application.isPlaying)
            {
                return;
            }
#endif
            OnTick?.Invoke(Time.deltaTime);
        }
예제 #27
0
 private void Timer_Elapsed(object sender, ElapsedEventArgs e)
 {
     _TimeLeft--;
     if (_TimeLeft <= 0)
     {
         _Timer.Stop();
         OnFinished?.Invoke();
     }
     OnTick?.Invoke();
 }
예제 #28
0
파일: Timer.cs 프로젝트: ntngel1/Chip8Emu
        public void Update()
        {
            deltaTime += clock.ElapsedTime.AsSeconds();
            clock.Restart();

            if (deltaTime >= timeUntilTick)
            {
                OnTick?.Invoke();
                deltaTime = 0;
            }
        }
예제 #29
0
 private void Tick()
 {
     if (elapsedTime > durationBetweenTicks)
     {
         elapsedTime = 0f;
         OnTick?.Invoke();
         EndTick?.Invoke();
     }
     elapsedTime += Time.deltaTime * _speed;
     ratio        = Mathf.Clamp01(elapsedTime / durationBetweenTicks);
 }
예제 #30
0
 static Rhythm()
 {
     timer          = new Timer();
     timer.Interval = Interval;
     timer.Elapsed += (object sender, ElapsedEventArgs args) => { if (Running)
                                                                  {
                                                                      Tick++; OnTick.Invoke(BeatInTick);
                                                                  }
     };
     timer.Start();
 }