public void Count() { while (ShouldCount) { long beginTime = DateTime.Now.Ticks; try { CurrentTime.Timer(); TimeLabel.Invoke(new Action(() => TimeLabel.Text = CurrentTime.ToString())); Distance += (Speed / 3600); DistanceLabel.Invoke(new Action(() => DistanceLabel.Text = $"{Distance:f2}")); RPM = Speed * 2.8; RpmLabel.Invoke(new Action(() => RpmLabel.Text = RPM.ToString())); Pulse = 90 + (int)((Power / 6) * (Speed / 10)); PulseLabel.Invoke(new Action(() => PulseLabel.Text = Pulse.ToString())); SpeedTrackbar.Invoke(new Action(() => SpeedTrackbar.Value = (int)Speed)); SpeedLabel.Invoke(new Action(() => SpeedLabel.Text = Speed.ToString())); PowerTrackbar.Invoke(new Action(() => PowerTrackbar.Value = (int)Power)); PowerLabel.Invoke(new Action(() => PowerLabel.Text = Power.ToString())); } catch (Exception e) { } Wait1s(beginTime); } }
public void Count() { while (ShouldCount) { try { CurrentTime.Timer(); TimeLabel.Invoke(new Action(() => TimeLabel.Text = CurrentTime.ToString())); Distance += (Speed / 3600); DistanceLabel.Invoke(new Action(() => DistanceLabel.Text = $"{Distance:f2}")); RPM = Speed * 2.8; RpmLabel.Invoke(new Action(() => RpmLabel.Text = RPM.ToString())); Pulse = 90 + (int)((Power / 6) * (Speed / 20)); PulseLabel.Invoke(new Action(() => PulseLabel.Text = Pulse.ToString())); SpeedTrackbar.Invoke(new Action(() => SpeedTrackbar.Value = (int)Speed)); SpeedLabel.Invoke(new Action(() => SpeedLabel.Text = Speed.ToString())); PowerTrackbar.Invoke(new Action(() => PowerTrackbar.Value = (int)Power)); PowerLabel.Invoke(new Action(() => PowerLabel.Text = Power.ToString())); } catch (Exception e) { } Thread.Sleep(1000); } }
private void SetTime(string time) { if (TimeLabel.InvokeRequired) { TimeLabel.Invoke(new MethodInvoker(() => { SetTime(time); })); } TimeLabel.Text = time; }
private Task UpdateTime() { return(Task.Run(() => { while (updateTime) { TimeLabel.Invoke(new Action(() => TimeLabel.Text = DateTime.Now.ToString())); } })); }
private void UpdateUI() { if (TimeLabel.InvokeRequired) { var d = new SafeCallDelegate(UpdateUI); TimeLabel.Invoke(d, new object[] { }); } else { TimeLabel.FitText(Stopwatch.Elapsed.ToString().Substring(0, 8), 999); } }