ScheduleTaskHelper.Infrastructure 1.0.7

dotnet add package ScheduleTaskHelper.Infrastructure --version 1.0.7
                    
NuGet\Install-Package ScheduleTaskHelper.Infrastructure -Version 1.0.7
                    
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="ScheduleTaskHelper.Infrastructure" Version="1.0.7" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="ScheduleTaskHelper.Infrastructure" Version="1.0.7" />
                    
Directory.Packages.props
<PackageReference Include="ScheduleTaskHelper.Infrastructure" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add ScheduleTaskHelper.Infrastructure --version 1.0.7
                    
#r "nuget: ScheduleTaskHelper.Infrastructure, 1.0.7"
                    
#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.
#:package ScheduleTaskHelper.Infrastructure@1.0.7
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=ScheduleTaskHelper.Infrastructure&version=1.0.7
                    
Install as a Cake Addin
#tool nuget:?package=ScheduleTaskHelper.Infrastructure&version=1.0.7
                    
Install as a Cake Tool

ScheduleTaskHelper.Infrastructure

ScheduleTaskHelper.Infrastructure is a robust task scheduling and execution framework designed for .NET applications. It supports various task scheduling modes (including timed and Cron expressions) and integrates distributed lock mechanisms, task retry queues, and event-driven architecture to ensure reliable and efficient task execution. Additionally, the framework supports a plugin-based architecture, allowing dynamic loading of external plugins, making it suitable for distributed systems or applications requiring efficient task management.

Features

  • Distributed Lock Mechanisms: Provides Redis-based and in-memory distributed lock implementations to ensure safe execution across multiple nodes.
  • Task Scheduling: Includes interfaces and utilities for defining and executing scheduled tasks.
  • Retry Queues: Supports task retry mechanisms for handling failures.
  • Event-Driven Architecture: Enables event-based task execution and monitoring.
  • Plugin Architecture: Allows dynamic loading and management of external plugins.

Key Components

Locks

  • RedisDistributedLockProvider: Implements distributed locks using Redis.
  • InMemoryDistributedLockProvider: Provides an in-memory implementation of distributed locks for simpler use cases.
  • RedisLockOptions: Configuration options for Redis-based locks.

Tasks

  • IScheduledTask: Interface for defining scheduled tasks with properties like name, group, priority, and execution logic.
  • ICronScheduledTask: Extends IScheduledTask to support Cron-based scheduling.

Rules

  • IRules: Interface for defining validation rules for tasks.

Reports

  • IReport: Interface for generating reports from tasks.

Utilities

  • BatchProcessingUtils: Utility class for batch processing tasks.

Cache

  • CacheManager: Provides caching capabilities for task management.

Getting Started

Prerequisites

  • .NET 8.0 SDK
  • Redis (if using RedisDistributedLockProvider)

Installation

  1. Clone the repository.
  2. Navigate to the ScheduleTaskHelper.Infrastructure project directory.
  3. Build the project using the .NET CLI:
    dotnet build
    

Usage

Define a Task

Implement the IScheduledTask or ICronScheduledTask interface to define your task logic:

public class MyTask : IScheduledTask
{
    public string Name => "MyTask";
    public string Group => "Default";
    public TimeSpan InitialDelay => TimeSpan.FromSeconds(10);
    public TimeSpan Period => TimeSpan.FromMinutes(1);
    public int Priority => 1;

    public Task<int> Execute()
    {
        Console.WriteLine("Executing MyTask");
        return Task.FromResult(0);
    }

    public void Stop()
    {
        Console.WriteLine("Stopping MyTask");
    }
}
Use Distributed Locks

Configure and use the RedisDistributedLockProvider or InMemoryDistributedLockProvider:

var redisLockProvider = new RedisDistributedLockProvider(redisConnection, options);
var distributedLock = await redisLockProvider.AcquireLockAsync("resourceName", "owner", TimeSpan.FromSeconds(30), TimeSpan.FromSeconds(10));

if (distributedLock != null)
{
    // Perform critical section
    await distributedLock.ReleaseAsync();
}

Contributing

Contributions are welcome! Please fork the repository and submit a pull request.

License

This project is licensed under the MIT License. See the LICENSE file for details.

Product Compatible and additional computed target framework versions.
.NET net7.0 is compatible.  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 is compatible.  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.  net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (2)

Showing the top 2 NuGet packages that depend on ScheduleTaskHelper.Infrastructure:

Package Downloads
ScheduleTaskHelper.Plugins

ScheduleTaskHelper.Plugins 是一個專為 .NET 應用程式設計的插件式架構框架,提供動態載入與管理外部插件的能力。此框架支援插件的初始化、服務註冊、任務管理與卸載,並透過標準化的介面與基底類別,簡化插件的開發與整合。適用於需要高擴展性與模組化設計的應用場景。

ScheduleTaskHelper.Tasks

ScheduleTaskHelper.Tasks 是一個專為 .NET 應用程式設計的任務排程框架,提供多種任務排程模式,包括定時任務與 Cron 表達式排程。此框架支援任務優先級管理、執行狀態追蹤與重試機制,並可與插件架構無縫整合,適用於需要高效任務管理的應用場景。

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.7 10 8/20/2025
1.0.6 9 8/20/2025
1.0.5 13 8/20/2025
1.0.4 11 8/20/2025
1.0.3 9 8/20/2025
1.0.2 9 8/20/2025
1.0.1 13 8/20/2025
1.0.0 11 8/20/2025