Snippets

Reach Media Network Example test for new ping code

Created by Nathan Davis
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp3
{
    class Program
    {
        static void Main(string[] args)
        {
            var now = DateTime.Now;
            var rand = new Random();

            for (var i = 0; i < 10; ++i)
            {
                // one second stagger to make sure it starts after the first remediation
                int staggerBy = 1;
                foreach (var p in new[] {
                    new {
                    Interval = 120
                },
                new {
                    Interval = 120
                }
                }) {
                    staggerBy += 60;

                    int randomPing = rand.Next(0, p.Interval);

                    DateTime toStart = DateTime.Now.Add(new TimeSpan(0, 0, staggerBy + randomPing));

                    Console.WriteLine((toStart - now).TotalSeconds);
                }

                Console.WriteLine();
            }

            Console.WriteLine("Press any key to exit . . .");
            Console.ReadKey();
        }
    }
}

Comments (0)

HTTPS SSH

You can clone a snippet to your computer for local editing. Learn more.