PollWatcher 1.0.0

dotnet add package PollWatcher --version 1.0.0
NuGet\Install-Package PollWatcher -Version 1.0.0
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="PollWatcher" Version="1.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add PollWatcher --version 1.0.0
#r "nuget: PollWatcher, 1.0.0"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install PollWatcher as a Cake Addin
#addin nuget:?package=PollWatcher&version=1.0.0

// Install PollWatcher as a Cake Tool
#tool nuget:?package=PollWatcher&version=1.0.0

PollWatcher

PollWatcher provides a way to register handler delegates to poll-based monitoring solutions. This enables event-driven development in scenarios where events are not provided and cannot easily be added. Possible use-cases include: polling a remote file server for changes, monitoring responses from an API, creating a recurring database task, etc. Built leveraging the System.Reactive namespace

Example (C# 9.0 syntax):

internal static class Program
{
    private static void Main()
    {
        using var watcher      = new PollWatcher<DateTime>(GetDate, interval, PrintDate, PrintException);
        // using var asyncWatcher = new AsyncPollWatcher<DateTime>(GetDateAsync, interval, PrintDate, PrintException);
        Thread.Sleep(5000);
    }

    // Returns a value that changes over time but must be retrieved synchronously
    // In this case, it's the time
    private static DateTime GetDate() => DateTime.Now;
    
    // Returns a value that changes over time but must be retrieved asynchronously
    // In this case, it's the time
    private static async Task<DateTime> GetDateAsync() => await Task.Run(() => DateTime.Now);

    //Specifies polling should occur every .001ms (if possible)
    private static TimeSpan interval = TimeSpan.FromMilliseconds(.001);

    // "Does stuff" with the data retrieved from polling
    // In this case, we print it to the console
    private static void PrintDate(DateTime dateTime) => Console.WriteLine(dateTime.ToString("O"));

    // "Does stuff" with exceptions raised during polling
    // In this case, we print it to the console
    private static void PrintException(Exception exception) => Console.WriteLine($"Exception!!!\t{exception.Message}");
}
Product Compatible and additional computed target framework versions.
.NET net5.0 is compatible.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net46 is compatible.  net461 is compatible.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.0 354 1/20/2021