void updateTimeUI(object sender, EventArgs e) { TimeArgs args = e as TimeArgs; mTime.text = ((int)args.curTime).ToString(); mTimeSlider.value = args.curTime / args.Time; }
//每个一秒触发一次Tick事件 //每个一分钟触发一次Clock事件 public void Start(TimeArgs timeArgs) { //获取当前时间 DateTime now = DateTime.Now; var eventArgs = new TimeArgs(now.Hour, now.Minute, now.Second); while (true) { eventArgs.Seconds++; OnTick(eventArgs); Thread.Sleep(1000); if (!eventArgs.Equals(timeArgs)) { continue; } OnClock(eventArgs); } }
private void OnClock(TimeArgs eventArgs) { Clock?.Invoke(this, eventArgs); }
private void OnTick(TimeArgs tickArgs) { Tick?.Invoke(this, tickArgs); }