public void updateTimeLabel() { // Do some string manipulation here (format: 00:00) TimeSpan ts = stopWatch.Elapsed; string result = ""; if (Math.Floor(Math.Log10(ts.Seconds) + 1) == 1) { result = ts.Minutes + ":0" + ts.Seconds; } else { result = ts.Minutes + ":" + ts.Seconds; } Control[] controls = Controls.Find("timeElapsedLabel", true); if (controls.Length == 1) { Label lab = controls[0] as Label; if (lab.InvokeRequired) { WindowActionCallBack d = new WindowActionCallBack(updateTimeLabel); Invoke(d, new object[] { }); } else { lab.Text = "Time Elapsed: " + result; } } }
public void incrementPenaltyLabel(PlayWindow window) { Control[] controls = window.Controls.Find("penaltyLabel", true); if (controls.Length == 1) { Label lab = controls[0] as Label; if (lab.InvokeRequired) { WindowActionCallBack d = new WindowActionCallBack(incrementPenaltyLabel); Invoke(d, new object[] { window }); } else { playerPenalty++; lab.Text = "Intentos: " + playerPenalty; } } }