AgentPoolManager.Core 1.0.0

.NET Core 3.1
dotnet add package AgentPoolManager.Core --version 1.0.0
NuGet\Install-Package AgentPoolManager.Core -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="AgentPoolManager.Core" Version="1.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add AgentPoolManager.Core --version 1.0.0
#r "nuget: AgentPoolManager.Core, 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 AgentPoolManager.Core as a Cake Addin
#addin nuget:?package=AgentPoolManager.Core&version=1.0.0

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

Agent Pool Manager Core

Manages a pool of asynchronous methods (agents) that keep repeating at a given interval until they are requested to stop. This lets your IIS Web applicaiton runs a pool of tasks in the background.


This nuGet has only one public class implementing the following interface


using System;
using System.Collections.Generic;
using System.Threading;

namespace pvWay.AgentPoolManager.Core
    public interface IAgentPoolManager
        IEnumerable<IAgent> Agents { get; }

        IAgent GetAgent(Guid id);

        IAgent StartAgent<T>(
            string title,
            Action<T> repeat,
            T workerParam,
            TimeSpan sleepSpan,
            ThreadPriority priority = ThreadPriority.Normal,
            Action<IAgent> stopCallback = null);

        IAgent StartAgent(
            string title,
            Action repeat,
            TimeSpan sleepSpan,
            ThreadPriority priority = ThreadPriority.Normal,
            Action<IAgent> stopCallback = null);


using System;

namespace pvWay.AgentPoolManager.Core
    public interface IAgent
        Guid Id { get; }
        DateTime StartTimeUtc { get; }
        string Title { get; }
        void RequestToStop();


See here after a short Console that use the pool


  • Create a method (with or without parameter) that you want to repeatedly invoke in background
  • Determine the interval of time between two invocations of your method
  • Instantiate the PoolManager (you can wrap/inject this class into/as a Singleton)
  • Add your method into the Agent Pool and in return get a IAgent reference
  • Stop the method at any time by calling the IAgent RequestToStop method

The following example shows the code for a simple clock pulsar that write the time in the console every 5 seconds.

The code

using System;
using System.Threading;
using pvWay.AgentPoolManager.Core;

namespace AgentPoolManagerLab.Core
    internal static class Program
        private static void Main(/*string[] args*/)
            var apm = new PoolManager();

            var pulsar = apm.StartAgent(
                // the name of the asynchronous agent
                // the method to repeat asynchronously
                // the string param passed to the Pulsar method
                // time between each invocation
                // the priority
                // the lambda that is called when the pulsar is stopped
                agent => Console.WriteLine($"{agent.Title} is stopped"));

            Console.WriteLine("hit a key to stop");


            Console.WriteLine("hit a key to quit");

        private static void Pulsar(string prefix)


Happy coding

Product Versions
.NET net5.0 net5.0-windows net6.0 net6.0-android net6.0-ios net6.0-maccatalyst net6.0-macos net6.0-tvos net6.0-windows net7.0 net7.0-android net7.0-ios net7.0-maccatalyst net7.0-macos net7.0-tvos net7.0-windows
.NET Core netcoreapp3.1
Compatible target framework(s)
Additional computed target framework(s)
Learn more about Target Frameworks and .NET Standard.
  • .NETCoreApp 3.1

    • No dependencies.

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 367 8/25/2020