Пример #1
0
        private void ThreadNotifications(object @object)
        {
            if (!(@object is NotificationThreadStart))
            {
                throw new ArgumentException("Could not start this thread");
            }
            NotificationThreadStart notificationThreadStart = (NotificationThreadStart)@object;
            NotificationsController controller = new NotificationsController();

            do
            {
                Thread.Sleep(notificationThreadStart.UpdateDelay);
                var requestThread = controller.GetNotificationsAsync(notificationThreadStart.LoginToken, notificationThreadStart.ValidKey);
                requestThread.Wait();
                Notification[] notifications = requestThread.Result;
                if (notifications != null)
                {
                    foreach (var notification in notifications)
                    {
                        NewNotification.Invoke(null, new NewNotificationArgs(notification, DateTime.Now));
                    }
                }
            } while (Thread.CurrentThread.ThreadState == ThreadState.Running);
        }