public void Start(int seconds = 1) { Device.StartTimer(TimeSpan.FromSeconds(seconds), () => { if (IsRunning) { StartTime += TimeSpan.FromSeconds(1); RemainTime = (EndTime - StartTime); var ticked = RemainTime.TotalSeconds >= 0; if (ticked) { Ticked?.Invoke(); } else { Completed?.Invoke(); } return(ticked); } return(true); }); }
// Only called on Ticks protected virtual void OnTicked(object source) { Ticked?.Invoke(source, EventArgs.Empty); // TODO: Play Tick Sound OnTickTocked(this); }
public void Start(int seconds = 1) { stopTimer = false; DisplayTime = new TimeSpan(0, Minutes, 0); // Invoke timer every second Device.StartTimer(TimeSpan.FromSeconds(seconds), () => { if (stopTimer) { return(false); } DisplayTime = DisplayTime.Subtract(new TimeSpan(0, 0, seconds)); var ticked = DisplayTime.TotalSeconds > 1; if (ticked) { Ticked?.Invoke(); } else { Completed?.Invoke(); } return(ticked); }); }
public void Start(int seconds = 1) { Device.StartTimer(TimeSpan.FromSeconds(seconds), () => { RemainTime = (EndDate.AddSeconds(1) - DateTime.Now); var ticked = RemainTime.TotalSeconds >= 1; if (ticked) { Ticked?.Invoke(); } else { Completed?.Invoke(); // count = 0; } if (Cancelar) { ticked = false; Cancel?.Invoke(); } return(ticked); }); }
public void Start() { TimeSpan endTime = new TimeSpan(DateTime.Now.Hour, DateTime.Now.Minute, DateTime.Now.Second).Add(TimeLeft); if (!isRunning) //if it is already running ther's no meaning for starting again { Device.StartTimer(TimeSpan.FromMilliseconds(SpreedControl()), () => { isRunning = true; TimeSpan nowTime = new TimeSpan(DateTime.Now.Hour, DateTime.Now.Minute, DateTime.Now.Second); TimeLeft = endTime - nowTime; var ticked = TimeLeft.TotalSeconds > 0; if (isPause) { Paused?.Invoke(); ticked = false; isRunning = false; } else if (ticked) { Ticked?.Invoke(); } else { Completed?.Invoke(); } return(ticked); }); } }
private void OnTicked() { if (LastExecutionStatus == Status.Failure || LastExecutionStatus == Status.Success) { Ticked?.Invoke(this, $"Node #{Id} - {Name} returned status: {LastExecutionStatus}"); } }
private void BackgroundWorkerOnDoWork(object sender, DoWorkEventArgs doWorkEventArgs) { var msSinceLastTick = (DateTime.Now - _lastTickAt).TotalMilliseconds; Ticked?.Invoke(msSinceLastTick); _lastTickAt = DateTime.Now; }
/// <summary> /// Timer tick for animation /// </summary> /// <param name="sender">Sender of this tick</param> /// <param name="e">Timer tick arguments</param> private void HandleTimerElapse(object sender, ElapsedEventArgs e) { if (IsRunning) { var ticks = (_stopwatch.ElapsedTicks - _stopwatchStart) / _durationTicks; var changeType = (ticks >= 1.0) ? ChangeType.Discrete : ChangeType.Continuous; Ticked?.Invoke(sender, new AnimationEventArgs(ticks, changeType)); } }
/// <summary> /// Starts the ticker and invokes Ticked event when there is a tick. /// </summary> /// public async Task StartAsync() { _ticker = new Task(() => { Task.Delay(IntervalMilliseconds); Ticked?.Invoke(this, new EventArgs()); }, tokensource.Token); await _ticker; }
private void OnTimerTicked(object state) { if (Interlocked.Exchange(ref _lock, 1) == 1 && _onlyOneMode) { Interlocked.Exchange(ref _newTick, 1); return; } Ticked?.Invoke(this, new EventArgs()); if (Interlocked.Exchange(ref _newTick, 0) == 1 && _onlyOneMode) { Ticked?.Invoke(this, new EventArgs()); } Interlocked.Exchange(ref _lock, 0); }
public async Task <ApplicationState> Next() { if (!clock.IsRunning) { return(ApplicationState.Shutdown); } var wait = options.TargetRate - (clock.Elapsed - last); if (wait > TimeSpan.Zero) { await Task.Delay(wait); } last = clock.Elapsed; Ticked?.Invoke(this, e: new LoopTickedEventArgs(last)); return(ApplicationState.Running); }
void OnAudioFilterRead(float[] data, int channels) { if (!running) { return; } double samplesPerTick = sampleRate * TimeBetweenBeats * 4.0F / signatureLo; double sample = AudioSettings.dspTime * sampleRate; int dataLen = data.Length / channels; int n = 0; while (n < dataLen) { float x = gain * amp * Mathf.Sin(phase); int i = 0; while (i < channels) { data[n * channels + i] += x; i++; } while (sample + n >= nextTick) { nextTick += samplesPerTick; amp = 1.0F; bool accented = ++accent > signatureHi; if (accented) { accent = 1; amp *= 2.0F; } //Debug.Log("Tick #" + totalTicks + ": " + accent + " / " + signatureHi); pendingBeats++; Ticked?.Invoke(pendingBeats, GetTotalElapsed(), accented); lastTickTime = AudioSettings.dspTime; } phase += amp * 0.3F; amp *= 0.993F; n++; } }
public void Start(int seconds = 1) { Device.StartTimer(TimeSpan.FromSeconds(seconds), () => { RemainTime = (EndDate - DateTime.Now); var ticked = RemainTime.TotalSeconds > 1; if (ticked) { Ticked?.Invoke(); } else { Completed?.Invoke(); } return(ticked); }); }
public void Start() { // Run for 24 hours const int MinutesInADay = 60 * 24; for (var i = 0; i < MinutesInADay; i++) { ClockTime = ClockTime.AddMinutes(1); Ticked.Invoke(this, ClockTime); var timeRemaining = ClockTime .Subtract(AlarmTime) .TotalMinutes; if (IsTimeToWakeUp(timeRemaining)) { OnWakeUp(); break; } }
void Update() { if (!init) { return; } if (!running) { Debug.LogFormat("Now: {0}, Expected start: {1}", AudioSettings.dspTime, startTick); if (AudioSettings.dspTime >= startTick) { Debug.Log("LET'S GO"); running = true; } else { return; } } double now = AudioSettings.dspTime; double delta = now; bool willPlay = false; int skipped = 0; bool accent = (curAccentMarker % signatureHi) == 0; while (delta >= nextTick) { delta -= TimeBetweenBeats; willPlay = true; pendingBeats++; skipped++; lastTickTime = now; Ticked?.Invoke(pendingBeats, GetTotalElapsed(), accent); } if (willPlay) { nextTick += skipped * TimeBetweenBeats; curAccentMarker += skipped; source.PlayOneShot(accent ? metroAccent : metroDefault); } }
private IEnumerator PlayEnumerator() { IsPlaying = true; var targetTime = Time.realtimeSinceStartup + HandTime; while (Time.realtimeSinceStartup <= targetTime) { var timeLeft = targetTime - Time.realtimeSinceStartup; var progress = timeLeft / HandTime; Ticked?.Invoke(progress); yield return(new WaitForFixedUpdate()); } Ticked?.Invoke(0); //in the new design you don't reach here if cancelled Elapsed?.Invoke(currentTurn); IsPlaying = false; }
public virtual Task TickAsync() { Ticked?.Invoke(this, null); return(Task.CompletedTask); }
protected virtual void OnTicked(PlayerEventArgs e) { Ticked?.Invoke(this, e); }
void OnTicked(EventArgs e) => Ticked?.Invoke(this, e);
private void TimerElapsed(object sender, ElapsedEventArgs e) { ElapsedSeconds++; Ticked?.Invoke(this, EventArgs.Empty); }
/// <summary> /// Backtesting: called once for each time step, if there was at least one tick or bar /// </summary> protected virtual void RaiseTicked() { Ticked?.Invoke(); }
private void Tick() { Ticked?.Invoke(); }
private void OnTicked() { Ticked?.Invoke(this, EventArgs.Empty); }
void ExecuteTick() { Ticked?.Invoke(); }
protected virtual void OnTicked() => Ticked?.Invoke(this, EventArgs.Empty);
private void BeforeTick() { Ticked?.Invoke(this, $"Node #{Id} - {Name} is going to tick"); }
private void OnSqwInterrupt(object sender, PinValueChangedEventArgs e) { Ticked?.Invoke(sender, new ClockTickedEventArgs(ds3231.DateTime)); }
private void OnTicked() { Ticked?.Invoke(this, new TickedEventArgs(CurrentTime)); }