private void clockRun(Object o) { while (true) { String now = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); ClockCallBackDelegate cbc = o as ClockCallBackDelegate; cbc(now); Thread.Sleep(1000); } }
public main() { InitializeComponent(); readEmailByXML(); //创建一个线程,用来实现时钟 ClockCallBackDelegate cbc = clockCallBack; Thread threadClock = new Thread(new ParameterizedThreadStart(clockRun)); threadClock.IsBackground = true; threadClock.Name = "clock"; threadClock.Start(cbc); this.threadList.Add(threadClock); }