示例#1
0
        /// <summary>
        /// Stellt den Empfang einer Quelle sicher.
        /// </summary>
        /// <param name="source">Die gewünschte Quelle.</param>
        public void EnsureFeed(SourceSelection source)
        {
            // Unregister all outstanding requests
            ResetFeeds();

            // Stop current reader if active - and wait for cancel to finish
            if (m_groupReader != null)
            {
                m_groupReader.Cancel();
                m_groupReader.Wait();
            }

            // Create new
            m_groupReader = ProviderDevice.Activate(source);
            m_feeds       = _NoFeeds;

            // Start processing
            m_feedAwaiter = m_groupReader.ContinueWith(task =>
            {
                // Load feed data
                var sources = task.Result;
                if (sources != null)
                {
                    if (IsAllocated)
                    {
                        return(m_feeds = sources.Select(sourceOnGroup => new Feed(sourceOnGroup, this)).ToArray());
                    }
                }

                // None
                return(null);
            });
        }
示例#2
0
        /// <summary>
        /// Beendet die Nutzung dieses Senders.
        /// </summary>
        public void RefreshSourceInformation()
        {
            if (m_reader != null)
            {
                m_reader.Cancel();
                m_reader.Wait();
            }

            m_reader = null;
        }
示例#3
0
 public static void Stop(bool _applicationExiting = false)
 {
     applicationExiting = _applicationExiting;
     if (!applicationExiting)
     {
         task.Stop();
     }
     else
     {
         task.Wait();
     }
 }
 protected virtual void WaitForCancellation()
 {
     try
     {
         Logger.Debug <CancellableTaskExecutor>($"{nameof(CancellableTask)} cancelling");
         CancellableTask.Wait();
         Logger.Debug <CancellableTaskExecutor>($"{nameof(CancellableTask)} cancelled");
     }
     catch (AggregateException)
     {
         Logger.Trace <CancellableTaskExecutor>($"Handling {nameof(AggregateException)} thrown from {nameof(CancellableTask)}");
     }
     catch (Exception ex)
     {
         Logger.Error <CancellableTaskExecutor>(ex, $"Handling unexpected error: {ex.Message}");
     }
 }
 protected virtual void Execute()
 {
     AppDomain.CurrentDomain.ProcessExit += OnProcessExit;
     CancellableTask = Task.Run(() => Command(CancellationTokenSource.Token), CancellationTokenSource.Token);
     CancellableTask.Wait(CancellationTokenSource.Token);
 }
 public void Wait()
 {
     scraperTask.Wait();
 }