private void onTimerTick(object sender, EventArgs e) { DateTime current_datetime = DateTime.Now; String key = Utils.GetDateString(current_datetime); int hash_key = key.GetHashCode(); List <Event> events = mEventData.DateOfEvents(hash_key); if (events != null) { foreach (Event evt in events) { if (evt.Type != 1) { continue; } if (evt.closed == 1) { continue; } if (this.inTimer(evt.Time, current_datetime)) { if (mEventMessage == null) { mEventMessage = new EventRemind(); mEventMessage.FormClosed += onEventCloseHandler; mEventMessage.Show(); } mEventMessage.initView(evt, string.Format("{0:00}:{1:00}:{2:00}", current_datetime.Hour, current_datetime.Minute, current_datetime.Second)); } } } //每隔10分钟存储数据一次 TimeSpan diff = current_datetime - mLastRecordSaveTime; if (diff.Minutes > 10) { mLastRecordSaveTime = current_datetime; mEventData.SaveEventData(); } }
private void onEventCloseHandler(object sender, EventArgs e) { mEventMessage.FormClosed -= onEventCloseHandler; mEventMessage = null; refreshEventList(); }