日期:2014-05-18 浏览次数:20807 次
public partial class MainWindow : Form { UpdateData Update = UpdateData.GetInstance(); SystemClock Clock = SystemClock.GetInstance(); public MainWindow() { InitializeComponent(); } private void btnStart_Click(object sender, EventArgs e) { Update.Start(); Clock.Start(); } private void btnStart_Click(object sender, EventArgs e) { Update.End(); Clock.End(); } } public sealed class SystemClock { // Singleton public static readonly SystemClock instance = new SystemClock(); public static SystemClock GetInstance() { return instance; } TimingController Timing = new TimingController(); //启动了定时器去运行 Timing.Run Timing.Run(); } public class TimingController { UpdateData Update = UpdateData.GetInstance(); SystemClock Clock = SystemClock.GetInstance(); private void End() { Clock.End(); Update.End(); } }