Skip to content

Instantly share code, notes, and snippets.

using System;
using System.Text;
using System.Linq;
using System.Xml.Linq;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Globalization;
using System.Reflection;
@long2know
long2know / TaskRepeater.cs
Last active June 26, 2022 17:41
Simple Task Scheduler
/// <summary>
/// Simple repeater based on a timed interval
/// </summary>
public static class TaskRepeater
{
public static Task Interval(TimeSpan pollInterval, Action action, CancellationToken token, bool runImmediately = false)
{
// We don't use Observable.Interval:
// If we block, the values start bunching up behind each other.
return Task.Factory.StartNew(