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); } }