Beispiel #1
0
 public Timer(DateTime dateTime, string formatting = DefaultFormat)
 {
     format  = formatting;
     expires = dateTime;
     OnTick?.Invoke((expires - DateTime.UtcNow).ToString(format));
     Manager.OnTick += Tick;
 }
Beispiel #2
0
 void IPlayable.Stop()
 {
     _timer.Stop();
     Stop();
     Source = null;
     OnTick?.Invoke(this, new PlayerEventArgs(PercentProgress, Duration, Position));
 }
Beispiel #3
0
 /// <summary>
 /// Used to run in a loop. Invokes the OnTick event
 /// </summary>
 public void Tick()
 {
     if (CanTick())
     {
         OnTick?.Invoke();
     }
 }
Beispiel #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();
        }
Beispiel #5
0
 internal static void Tick()
 {
     if (OnTick != null)
     {
         OnTick.Invoke();
     }
 }
 private void InvokeOnTick()
 {
     if (OnTick != null)
     {
         OnTick.Invoke();
     }
 }
    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
        {
        }
    }
 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);
            }
        }
Beispiel #10
0
        public void Update()
        {
            Application.DoEvents();
            OnTick?.Invoke();

            GameForm.Update();
        }
Beispiel #11
0
 public static void Tick(GameModel gameModel)
 {
     if (gameModel.IsRunning)
     {
         OnTick.Invoke(gameModel);
     }
 }
        /// <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;
        }
Beispiel #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();
        }
Beispiel #14
0
 /// <summary>
 /// Internal tick process
 /// </summary>
 private void _TickThreadProc()
 {
     while (true)
     {
         OnTick?.Invoke();
         Sleep(Interval);
     }
 }
Beispiel #15
0
 private void Tick(object o)
 {
     if (Interlocked.CompareExchange(ref timerBusy, 1, 0) == 0)
     {
         OnTick?.Invoke();
         timerBusy = 0;
     }
 }
Beispiel #16
0
        private static IEnumerator Tick()
        {
            for (; IsRunning;)
            {
                yield return(new WaitForSeconds(0.25f));

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

            OnTick?.Invoke();
        }
    }
Beispiel #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);
     }
 }
Beispiel #21
0
 public Timer()
 {
     new System.Timers.Timer {
         Interval = 1000
     }.Elapsed += (sender, args) =>
     {
         OnTick?.Invoke(this, new TimeEventArgs(args.SignalTime));
     };
 }
Beispiel #22
0
 private void Count()
 {
     while (true)
     {
         Thread.Sleep(intInterval);
         AddPoints();
         OnTick?.Invoke(points);
     }
 }
        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();
        }
Beispiel #25
0
 private void T_Tick(object sender, EventArgs e)
 {
     _loopNo++;
     OnTick?.Invoke(this);
     if (_loopNo >= LoopCount)
     {
         T.Stop();
         OnFinished?.Invoke(this);
     }
 }
Beispiel #26
0
        /// <summary>
        /// Called by PlayerLoopSystem before each update
        /// </summary>
        void Tick()
        {
#if UNITY_EDITOR
            if (!Application.isPlaying)
            {
                return;
            }
#endif
            OnTick?.Invoke(Time.deltaTime);
        }
Beispiel #27
0
 private void Timer_Elapsed(object sender, ElapsedEventArgs e)
 {
     _TimeLeft--;
     if (_TimeLeft <= 0)
     {
         _Timer.Stop();
         OnFinished?.Invoke();
     }
     OnTick?.Invoke();
 }
Beispiel #28
0
        public void Update()
        {
            deltaTime += clock.ElapsedTime.AsSeconds();
            clock.Restart();

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