Exemple #1
0
        // Testing

        static async Task Test()
        {
            var pts  = new PauseTokenSource();
            var task = SomeMethodAsync(pts.Token);

            // sync version
            Console.WriteLine("Before pause requested");
            pts.PauseWithResponseAsync().Wait();
            Console.WriteLine("After pause requested, paused: " + pts.Token.IsPaused);
            pts.PauseWithResponseAsync().Wait();
            Console.WriteLine("After pause requested, paused: " + pts.Token.IsPaused);
            Console.WriteLine("Press enter to resume...");
            Console.ReadLine();
            pts.Resume();

            // async version:

            Console.WriteLine("Before pause requested");
            await pts.PauseWithResponseAsync();

            Console.WriteLine("After pause requested, paused: " + pts.Token.IsPaused);
            await pts.PauseWithResponseAsync();

            Console.WriteLine("After pause requested, paused: " + pts.Token.IsPaused);
            Console.WriteLine("Press enter to resume...");
            Console.ReadLine();
            pts.Resume();
        }
Exemple #2
0
 private void Resume()
 {
     _crawlerPauseTokenSource.Resume();
     _crawlerService.IsPaused = false;
     _pauseCommand.RaiseCanExecuteChanged();
     _resumeCommand.RaiseCanExecuteChanged();
 }
Exemple #3
0
        static void Main()
        {
            var pts  = new PauseTokenSource();
            var task = SomeMethodAsync(pts.Token);

            Task.Run(() =>
            {
                Console.WriteLine("Before pause requested");
                pts.PauseWithResponseAsync().Wait();
                Console.WriteLine("After pause requested.");
                pts.Resume();
            }).Wait();
            Console.ReadLine();

            // Alternatively, async version:

            /*
             * Func<Task> func = async () =>
             * {
             *              Console.WriteLine("Before pause requested");
             *              await pts.PauseWithResponseAsync();
             *              Console.WriteLine("After pause requested.");
             *              pts.Resume();
             * };
             * func().Wait();
             * Console.ReadLine();
             */
        }
Exemple #4
0
 private void Resume()
 {
     crawlerPauseToken.Resume();
     crawlerService.IsPaused = false;
     pauseCommand.RaiseCanExecuteChanged();
     resumeCommand.RaiseCanExecuteChanged();
 }
Exemple #5
0
        static async Task Test(CancellationToken token)
        {
            var pts  = new PauseTokenSource();
            var task = DoWorkAsync(pts.Token, token);

            while (true)
            {
                token.ThrowIfCancellationRequested();

                Console.WriteLine("Press enter to pause...");
                Console.ReadLine();

                Console.WriteLine("Before pause requested");
                await pts.PauseAsync();

                Console.WriteLine("After pause requested, paused: " + pts.IsPaused);

                Console.WriteLine("Press enter to resume...");
                Console.ReadLine();

                Console.WriteLine("Before resume");
                pts.Resume();
                Console.WriteLine("After resume");
            }
        }
 public void Resume()
 {
     crawlBlogsPause.Resume();
     crawlerService.IsPaused = false;
     pauseCommand.RaiseCanExecuteChanged();
     resumeCommand.RaiseCanExecuteChanged();
 }
Exemple #7
0
 public void NotifyCommandFinished()
 {
     _commandExecuting = false;
     if (IsPaused)
     {
         _pts.Resume();
     }
     RaiseCanExecuteChanged();
 }
Exemple #8
0
 private void buttonPause_Click(object sender, EventArgs e)
 {
     if (!paused)
     {
         buttonPause.Text = "Возобновить";
         myPause.Pause();
         paused = true;
         OnTimerPause();
     }
     else
     {
         buttonPause.Text = "Пауза";
         myPause.Resume();
         paused = false;
         OnTimerResume();
     }
 }
 /// <summary>
 ///     Resume send mail
 /// </summary>
 public void ResumeSendBulkMail()
 {
     _pauseTokenSource.Resume();
 }