TaskMaster 4.0.1

There is a newer version of this package available.
See the version list below for details.
dotnet add package TaskMaster --version 4.0.1
NuGet\Install-Package TaskMaster -Version 4.0.1
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="TaskMaster" Version="4.0.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add TaskMaster --version 4.0.1
#r "nuget: TaskMaster, 4.0.1"
#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 TaskMaster as a Cake Addin
#addin nuget:?package=TaskMaster&version=4.0.1

// Install TaskMaster as a Cake Tool
#tool nuget:?package=TaskMaster&version=4.0.1

TaskMaster

TaskMaster is a basic library to help with running tasks only after certain criteria are met.

Build status

Basic Usage

The system relies on an IoC wrapper called Canister. While Canister has a built in IoC container, it's purpose is to actually wrap your container of choice in a way that simplifies setup and usage for other libraries that don't want to be tied to a specific IoC container. TaskMaster uses it to detect and pull in various info. As such you must set up Canister in order to use TaskMaster:

Canister.Builder.CreateContainer(new List<ServiceDescriptor>())
                .RegisterTaskMaster()
                .Build();
				

You must also register any assemblies that will contain your tasks with Canister in order for the system to find them:

Canister.Builder.CreateContainer(new List<ServiceDescriptor>())
				.AddAssembly(typeof(MyTask).GetTypeInfo().Assembly)
                .RegisterTaskMaster()
                .Build();

This is required prior to using the TaskMaster class for the first time. Once Canister is set up, you can use the TaskMaster class:

var Manager = new TaskMaster.TaskMaster();
Manager.Run();

The TaskMaster class will handle discovery of tasks, prioritization, and running of tasks. It will also log any errors that it finds to Serilog. If Serilog is not registered to Canister, it will default to an empty logger that does nothing. However if one is specified it will log events as they occur to the ILogger class.

Creating a task

Creating a task is rather simple, you just need to inherit a class from ITask:

/// <summary>
/// Basic hello world task
/// </summary>
public class HelloWorldTask : ITask
{
    /// <summary>
    /// Gets the frequencies.
    /// </summary>
    /// <value>The frequencies.</value>
    public IFrequency[] Frequencies => new IFrequency[] { new RunAlways() };

    /// <summary>
    /// Gets the name.
    /// </summary>
    /// <value>The name.</value>
    public string Name => "Hello World";

	/// <summary>
    /// Order to run it in (items with the same Priority value will be run in parallel)
    /// </summary>
    public int Priority => 1;

    /// <summary>
    /// Executes the specified last run.
    /// </summary>
    /// <param name="lastRun">The last run.</param>
    /// <returns></returns>
    public bool Execute(DateTime lastRun)
    {
        Console.WriteLine("Hello World");
        return true;
    }

    /// <summary>
    /// Initializes the specified data manager.
    /// </summary>
    /// <param name="dataManager">The data manager.</param>
    /// <returns></returns>
    public bool Initialize(IDataManager dataManager)
    {
        return true;
    }
}

The above task runs every time the TaskManager's Run method is called. However you can specify another or even multiple frequencies at which to run. The name of the task is Hello World. As such all logged events will use that name. The priority is set to 1, which determines the batch they are run in. Lower numbered items are run first and if more than one task has the same priority, they will be run at the same time in parallel.

The Initialization function is called when the item is created. The function is passed in an IDataManager class that will handle saving/getting configuration data for the task. By default the data manager saves configuration data in json serialized strings but this can be changed by creating your own data manager.

The Execute function is called when the task is actually triggered. As such that is where your task's actual work should go.

Installation

The library is available via Nuget with the package name "TaskMaster". To install it run the following command in the Package Manager Console:

Install-Package TaskMaster

Build Process

In order to build the library you will require the following as a minimum:

  1. Visual Studio 2017

Other than that, just clone the project and you should be able to load the solution and build without too much effort.

Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  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. 
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
4.0.118 85 4/16/2024
4.0.117 71 4/15/2024
4.0.116 78 4/12/2024
4.0.115 83 4/11/2024
4.0.114 70 4/2/2024
4.0.113 75 4/1/2024
4.0.112 75 3/29/2024
4.0.111 88 3/19/2024
4.0.110 75 3/18/2024
4.0.109 76 3/15/2024
4.0.108 72 3/14/2024
4.0.107 72 3/12/2024
4.0.106 60 3/11/2024
4.0.105 75 3/8/2024
4.0.104 84 3/7/2024
4.0.103 83 3/6/2024
4.0.102 75 3/5/2024
4.0.101 90 3/4/2024
4.0.100 90 3/1/2024
4.0.99 78 2/29/2024
4.0.98 77 2/28/2024
4.0.97 80 2/27/2024
4.0.96 70 2/26/2024
4.0.95 71 2/23/2024
4.0.94 62 2/22/2024
4.0.93 86 2/21/2024
4.0.92 77 2/20/2024
4.0.91 79 2/19/2024
4.0.90 67 2/16/2024
4.0.89 86 2/15/2024
4.0.88 67 2/13/2024
4.0.87 80 2/12/2024
4.0.86 77 2/9/2024
4.0.85 85 2/8/2024
4.0.84 84 2/7/2024
4.0.83 74 2/6/2024
4.0.82 75 2/5/2024
4.0.81 77 2/2/2024
4.0.80 72 2/1/2024
4.0.79 77 1/31/2024
4.0.78 77 1/30/2024
4.0.77 75 1/26/2024
4.0.76 67 1/25/2024
4.0.75 74 1/24/2024
4.0.74 77 1/23/2024
4.0.73 76 1/22/2024
4.0.72 88 1/15/2024
4.0.71 85 1/12/2024
4.0.70 77 1/11/2024
4.0.69 99 12/26/2023
4.0.68 93 12/22/2023
4.0.67 93 12/20/2023
4.0.66 108 12/18/2023
4.0.65 108 12/15/2023
4.0.64 96 12/14/2023
4.0.63 97 12/13/2023
4.0.62 97 12/12/2023
4.0.61 161 11/27/2023
4.0.60 128 11/24/2023
4.0.59 126 11/22/2023
4.0.58 115 11/21/2023
4.0.57 119 11/20/2023
4.0.56 121 11/17/2023
4.0.55 113 11/16/2023
4.0.54 132 11/14/2023
4.0.53 115 11/14/2023
4.0.52 98 11/13/2023
4.0.51 114 11/10/2023
4.0.50 109 11/9/2023
4.0.49 108 11/8/2023
4.0.48 117 11/7/2023
4.0.47 132 11/6/2023
4.0.46 149 11/3/2023
4.0.45 139 11/2/2023
4.0.44 134 11/1/2023
4.0.43 115 10/31/2023
4.0.42 122 10/30/2023
4.0.41 133 10/27/2023
4.0.40 113 10/26/2023
4.0.39 119 10/13/2023
4.0.38 132 10/12/2023
4.0.37 122 10/5/2023
4.0.36 134 9/26/2023
4.0.35 127 9/21/2023
4.0.34 138 9/20/2023
4.0.33 135 9/19/2023
4.0.32 111 9/18/2023
4.0.31 136 9/15/2023
4.0.30 151 9/14/2023
4.0.29 133 9/13/2023
4.0.28 135 9/12/2023
4.0.27 151 9/11/2023
4.0.26 163 9/8/2023
4.0.25 149 9/7/2023
4.0.24 137 9/6/2023
4.0.23 153 9/5/2023
4.0.22 153 9/4/2023
4.0.21 147 9/1/2023
4.0.20 144 8/31/2023
4.0.19 146 8/30/2023
4.0.18 158 8/29/2023
4.0.17 142 8/28/2023
4.0.16 153 8/25/2023
4.0.15 124 8/24/2023
4.0.14 155 8/23/2023
4.0.13 184 8/21/2023
4.0.12 150 8/18/2023
4.0.11 148 8/17/2023
4.0.10 163 8/10/2023
4.0.9 170 8/9/2023
4.0.8 163 8/8/2023
4.0.7 152 8/8/2023
4.0.6 158 8/7/2023
4.0.5 182 8/3/2023
4.0.4 162 7/27/2023
4.0.3 164 7/26/2023
4.0.2 155 7/20/2023
4.0.1 155 7/17/2023
4.0.0 310 12/12/2022
3.1.3 522 6/10/2022
3.1.0 634 1/21/2022
3.0.15 466 1/11/2022
3.0.14 475 1/10/2022
3.0.13 467 6/21/2021
3.0.12 494 1/6/2021
3.0.11 505 11/23/2020
3.0.9 580 9/13/2020
3.0.8 545 6/8/2020
3.0.7 622 4/1/2020
3.0.6 570 3/25/2020
3.0.5 594 3/3/2020
3.0.4 630 1/29/2020
3.0.3 596 1/19/2020
3.0.2 683 12/31/2019
3.0.1 667 12/29/2019
3.0.0 606 12/23/2019
2.0.6 892 9/13/2018
2.0.5 943 7/26/2018
2.0.4 1,051 6/1/2018
2.0.3 1,006 6/1/2018
2.0.2 1,104 5/22/2018
2.0.1 1,234 2/5/2018
2.0.0 1,217 1/2/2018
1.0.10 1,086 9/29/2017
1.0.9 987 8/28/2017
1.0.8 1,028 8/11/2017
1.0.7 1,042 8/11/2017
1.0.6 1,070 8/11/2017
1.0.5 1,074 8/11/2017
1.0.4 1,029 8/11/2017
1.0.3 1,047 8/11/2017
1.0.2 1,034 8/11/2017