<commit_before>﻿using System;
using Turtle;

namespace TestApp
{
    class Program
    {
        private static void Main(string[] args)
        {
            Retry.This(() =>
            {
                Console.WriteLine("Hello");
                Throws();
            })
                .MaximumNumberOfTries(5)
                .Run();

            Retry.This(() =>
            {
                Console.WriteLine("Hello2");
                Throws();
            })
                .MaximumNumberOfTries(5)
                .RunAsync().Wait();

            Retry.This(() =>
            {
                Console.WriteLine("Hello3");
                return false;
            })
                .MaximumNumberOfTries(5)
                .Run();

            Retry.This(() =>
            {
                Console.WriteLine("Hello4");
                return false;
            })
                .Using(new LimitedExponentialBackofRetryStrategy
                {
                    BaseDelay = TimeSpan.FromMilliseconds(50),
                    MaxDelay = TimeSpan.FromSeconds(5)
                })
                .MaximumNumberOfTries(5)
                .Run();

            Retry.This(() =>
            {
                Console.WriteLine("just twice");
                Throws();
            })
                .MaximumNumberOfTries(2)
                .Run();

            Action a = (() => { Console.WriteLine("extension"); Throws(); });
            a.Retry().MaximumNumberOfTries(10).Run();

            Console.ReadLine();
        }

        public static void Throws()
        {
            throw new Exception();
        }
    }
}
<commit_msg>Added example using CancellationToken.<commit_after>﻿using System;
using System.Threading;
using Turtle;

namespace TestApp
{
    static class Program
    {
        private static void Main()
        {
            Retry.This(() =>
            {
                Console.WriteLine("Hello");
                Throws();
            })
                .MaximumNumberOfTries(5)
                .Run();

            Retry.This(() =>
            {
                Console.WriteLine("Hello2");
                Throws();
            })
                .MaximumNumberOfTries(5)
                .RunAsync().Wait();

            Retry.This(() =>
            {
                Console.WriteLine("Hello3");
                return false;
            })
                .MaximumNumberOfTries(5)
                .Run();

            Retry.This(() =>
            {
                Console.WriteLine("Hello4");
                return false;
            })
                .Using(new LimitedExponentialBackofRetryStrategy
                {
                    BaseDelay = TimeSpan.FromMilliseconds(50),
                    MaxDelay = TimeSpan.FromSeconds(5)
                })
                .MaximumNumberOfTries(5)
                .Run();

            Retry.This(() =>
            {
                Console.WriteLine("just twice");
                Throws();
            })
                .MaximumNumberOfTries(2)
                .Run();

            Action a = (() => { Console.WriteLine("extension"); Throws(); });
            a.Retry().MaximumNumberOfTries(10).Run();


            var tokenSource = new CancellationTokenSource();
            var t = Retry.This(() =>
            {
                Console.WriteLine("async");
                Throws();
            }).RunAsync(tokenSource.Token);

            tokenSource.CancelAfter(TimeSpan.FromSeconds(2));

            try
            {
                t.Wait(tokenSource.Token);
            }
            catch (OperationCanceledException)
            {}

            Console.ReadLine();
        }

        public static void Throws()
        {
            throw new Exception();
        }
    }
}

{'fraction_non_alphanumeric': 0.11234504132231404, 'fraction_numerical': 0.006973140495867769, 'mean_word_length': 0.9922839506172839, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 16, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4181366', 'n_tokens_mistral': 991, 'n_tokens_neox': 887, 'n_words': 140}