MethodQ.cs
/// <summary>
/// Schedules the specified <see cref="Action"/> to be executed every <paramref name="interval"/> until manual cancellation.
/// </summary>
/// <param name="action">The <see cref="Action"/> to schedule.</param>
/// <param name="interval">Repetition interval <see cref="TimeSpan"/>.</param>
/// <returns>The scheduled method call's unique identifier (needed for cancellation).</returns>
Schedules the specified  to be executed every  until manual cancellation.
Schedules the specified to be executed every until manual cancellation .
public ulong Schedule(Action action, TimeSpan interval)
        {
            if (action is null)
                throw new ArgumentNullException($"{nameof(MethodQ)}::{nameof(Schedule)}: The provided {nameof(action)} argument is null!");
            if (interval.TotalMilliseconds >= Int32.MaxValue)
                throw new ArgumentException($"{nameof(MethodQ)}::{nameof(Schedule)}: The provided {nameof(interval)} {nameof(TimeSpan)} is longer than {{Int32.MaxValue}} milliseconds, which is not allowed and not a good idea anyway (use a scheduled task for anything >3 days in the future).");
            ulong id = nextId++;
            var timer = new Timer(interval.TotalMilliseconds) { AutoReset = true };
            timer.Elapsed += (_, __) => action.Invoke();
            timer.Start();
            timers.Add(id, timer);
            return id;
        }
public ulong Schedule ( Action action , TimeSpan interval ) { if ( action is null ) throw new ArgumentNullException ( $" { nameof ( MethodQ ) } :: { nameof ( Schedule ) } : The provided  { nameof ( action ) }  argument is null! " ) ; if ( interval . TotalMilliseconds >= Int32 . MaxValue ) throw new ArgumentException ( $" { nameof ( MethodQ ) } :: { nameof ( Schedule ) } : The provided  { nameof ( interval ) } { nameof ( TimeSpan ) }  is longer than  {{ Int32.MaxValue}} milliseconds, which is not allowed and not a good idea anyway (use a scheduled task for anything >3 days in the future). " ) ; ulong id = nextId ++ ; var timer = new Timer ( interval . TotalMilliseconds ) { AutoReset = true } ; timer . Elapsed += ( _ , __ ) => action . Invoke ( ) ; timer . Start ( ) ; timers . Add ( id , timer ) ; return id ; }
Schedules the specified  to be executed every  until manual cancellation.
Schedules the specified to be executed every until manual cancellation .
The scheduled method call's unique identifier (needed for cancellation).
The scheduled method call ' s unique identifier ( needed for cancellation ) .
action
Action
The  to schedule.
The to schedule .
interval
TimeSpan
Repetition interval .
Repetition interval .