Exemple #1
0
        public static async Task Task1(IThrottler throttler)
        {
            Console.WriteLine("Sync throttler...  ");
            var stopwatch = Stopwatch.StartNew();

            for (var i = 0; i < 50; i++)
            {
                // Use sync mode. Will pause when requests made in the last period have reached the limit configured
                throttler.WaitForPermission();
                await Task.Delay(100);

                Console.WriteLine($"Sync - {i}");
            }
            Console.WriteLine($"{stopwatch.Elapsed.TotalSeconds:##.00} s");
        }