Example #1
0
        private void HandleSecondElapsed(object sender, ElapsedEventArgs e)
        {
            var utcNow = e.SignalTime.ToUniversalTime();

            if (utcNow.Hour == 12 && utcNow.Minute == 0 && utcNow.Second == 0)
            {
                EveryDayAtUtcNoon?.Invoke();
            }

            if (utcNow.Second == 0)
            {
                EveryFullMinute?.Invoke();
            }

            if (utcNow.Second % 30 == 0)
            {
                EveryHalfMinute?.Invoke();
            }

            if (utcNow.Second % 10 == 0)
            {
                EveryTenSeconds?.Invoke();
            }

            EverySecond?.Invoke();

            InvokeScheduledJobs();
        }
Example #2
0
        private void Update()
        {
            if (!Active)
            {
                return;
            }

            _secondsLeft -= Time.deltaTime;

            while (_secondsLeft < 0)
            {
                _secondsLeft += 1f;
                EverySecond?.Invoke();
            }
        }