Example #1
0
        private void SetRemindersForSession()
        {
            var reminderAggregates = reminderService.FindRemindersInNextHour();

            if (reminderAggregates == null || reminderAggregates.Count() == 0)
            {
                return;
            }
            foreach (var aggregate in reminderAggregates)
            {
                TimeSpan timeUntilReminder = aggregate.ReminderDate - DateTime.Now;
                if (timeUntilReminder < TimeSpan.Zero)
                {
                    return;
                }

                var timer = new System.Windows.Forms.Timer();
                timer.Interval = timeUntilReminder.Seconds * 1000;
                timer.Enabled  = true;
                timer.Tick    += new EventHandler((object sender, EventArgs e) =>
                {
                    timer.Enabled    = false;
                    var reminderForm = _formManager.GetForm <ReminderForm>();
                    reminderForm.SetAggregate(aggregate);
                    reminderForm.Show();
                });
            }
        }