コード例 #1
0
        private static void NotifySubscribersOnTimeEvent()
        {
            try
            {
                _Notifying = true;
                _Timer.Stop();
#if DEBUG
                Console.WriteLine("{0} NotificationServer notifying subscribers count: {1}", DateTime.Now, _RequestList.Count);
#endif
                // Reset next notification time...
                _NextEventTime = DateTime.MinValue;

                if (_RequestList.Count == 0)
                {
                    return;
                }
                DateTime now = CalendarModel.GetCalendarDateTime(UtcNow);
                NotificationRequest[] requestList = new NotificationRequest[_RequestList.Count];
                _RequestList.CopyTo(requestList);
                DateTime nextNotification = DateTime.MinValue;
                foreach (NotificationRequest item in requestList)
                {
                    if (item.NotificationTime <= now)
                    {
                        if (item.NotificationHandler != null)
                        {
                            //if (System.Threading.Thread.CurrentThread.ManagedThreadId != item.ThreadId)
                            //{
                                
                            //    //System.Threading.SendOrPostCallback callback = new System.Threading.SendOrPostCallback(SendNotification);
                            //    //System.Windows.Threading.DispatcherSynchronizationContext.Current.Post(callback, item);
                            //}
                            //else
                                item.NotificationHandler(item, new NotificationServerEventArgs(now));
                        }
                        _RequestList.Remove(item);
                    }
                    else if (item.NotificationTime < nextNotification || nextNotification == DateTime.MinValue)
                        nextNotification = item.NotificationTime;
                }

                if (nextNotification > DateTime.MinValue)
                {
                    SetNextEventTime(nextNotification);
                }
                //else
                //    Console.WriteLine("Not setting next notification time...");
            }
            finally
            {
                _Notifying = false;
            }
        }
コード例 #2
0
 public static void Unregister(NotificationRequest request)
 {
     _RequestList.Remove(request);
 }
コード例 #3
0
 public static void UpdateNotification(NotificationRequest request)
 {
     SetNextEventTime(request.NotificationTime);
 }
コード例 #4
0
 public static void Register(NotificationRequest request)
 {
     _RequestList.Add(request);
     SetNextEventTime(request.NotificationTime);
 }
コード例 #5
0
ファイル: Appointment.cs プロジェクト: huamanhtuyen/VNACCS
 private void OnStartTimeNotification(NotificationRequest request, NotificationServerEventArgs e)
 {
     if (_StartTimeAction != eStartTimeAction.None)
     {
         this.StartTimeNotificationRequest = null;
         ProcessStartTimeReachedActions();
     }
 }