예제 #1
0
        private void Update()
        {
            if (!_sema.WaitOne(10))
            {
                return;
            }

            var stp = StaticInstance.ThreadPool;
            //stp.MaxThreads = (int) _setti.NumFetchThreads;
            var results = new List <IWaitableResult>();

            foreach (FavShowData t in _setti.TvShows)
            {
                results.Add(stp.QueueWorkItem(data => data.Fetch(), t, true, ThreadPriority.AboveNormal)); //schedule update of show (executed paralell)
            }
            //wait for completion
            stp.QueueWorkItem(() =>
            {
                SmartThreadPool.WaitAll(results.ToArray());
                _sema.Release();

                var updates = _setti.TvShows.Where(show => show.NewEpisodes && !show.Notified).ToList();
                if (updates.Count > 0)
                {
                    updates.ForEach(show => show.Notified = true);

                    if (_setti.ShowNotifications)
                    {
                        Dispatcher.Invoke(() =>
                        {
                            var n              = new NotificationBalloon(updates);
                            n.ShowViewClicked += on_ShowViewClicked;

                            NotifyIcon.ShowCustomBalloon(n, PopupAnimation.Slide, _setti.NotificationTimeout <= 0 ? (int?)null : _setti.NotificationTimeout);
                        });
                    }
                }
            }, true, ThreadPriority.AboveNormal);
        }
예제 #2
0
        private void Update()
        {
            if (!_sema.WaitOne(10)) return;

            var stp = StaticInstance.ThreadPool;
            //stp.MaxThreads = (int) _setti.NumFetchThreads;
            var results = new List<IWaitableResult>();
            foreach (FavShowData t in _setti.TvShows)
            {
                results.Add(stp.QueueWorkItem(data => data.Fetch(), t,true,ThreadPriority.AboveNormal)); //schedule update of show (executed paralell)
            }
            //wait for completion
            stp.QueueWorkItem(() =>
                              {
                                  SmartThreadPool.WaitAll(results.ToArray());
                                  _sema.Release();

                                  var updates = _setti.TvShows.Where(show => show.NewEpisodes && !show.Notified).ToList();
                                  if (updates.Count > 0)
                                  {
                                      updates.ForEach(show => show.Notified = true);

                                      if (_setti.ShowNotifications)
                                      {
                                          Dispatcher.Invoke(() =>
                                                            {
                                                                var n = new NotificationBalloon(updates);
                                                                n.ShowViewClicked += on_ShowViewClicked;

                                                                NotifyIcon.ShowCustomBalloon(n, PopupAnimation.Slide, _setti.NotificationTimeout <= 0 ? (int?) null : _setti.NotificationTimeout);
                                                            });
                                      }
                                  }
                              }, true, ThreadPriority.AboveNormal);
        }