SimpleEventScheduler 1.0.2

dotnet add package SimpleEventScheduler --version 1.0.2
                    
NuGet\Install-Package SimpleEventScheduler -Version 1.0.2
                    
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="SimpleEventScheduler" Version="1.0.2" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="SimpleEventScheduler" Version="1.0.2" />
                    
Directory.Packages.props
<PackageReference Include="SimpleEventScheduler" />
                    
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 SimpleEventScheduler --version 1.0.2
                    
#r "nuget: SimpleEventScheduler, 1.0.2"
                    
#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 SimpleEventScheduler@1.0.2
                    
#: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=SimpleEventScheduler&version=1.0.2
                    
Install as a Cake Addin
#tool nuget:?package=SimpleEventScheduler&version=1.0.2
                    
Install as a Cake Tool

EventScheduler

.NET Standard NuGet License

A lightweight, high-performance .NET library for scheduling timed events with configurable warning systems. Perfect for game development, simulation environments, and any application requiring precise event timing and lifecycle management.

๐ŸŽฏ Features

  • โฐ Precise Event Scheduling: Chronological event ordering with efficient O(n) insertion
  • โš ๏ธ Warning System: Configurable advance warnings before event execution
  • ๐Ÿ”„ Event Lifecycle Management: Schedule, reschedule, cancel, and track events
  • ๐Ÿ—๏ธ Generic Architecture: Works with any IWorldDateTimeProvider implementation
  • ๐Ÿ“ฆ Builder Pattern: Fluent API for declarative event construction
  • ๐Ÿ” Event Querying: Retrieve events by ID or enumerate all scheduled events
  • ๐Ÿ“Š Observer Pattern: Event execution notifications and callbacks
  • โœ… 98.5% Test Coverage: Comprehensive unit and integration tests

๐Ÿš€ Quick Start

Basic Event Scheduling

using EventScheduler;
using EventScheduler.Abstractions;

// 1. Create a time provider (implement your own or use a mock)
public class GameTimeProvider : IWorldDateTimeProvider
{
    public DateTime CurrentTime { get; set; } = DateTime.Now;
}

// 2. Create an event scheduler
var scheduler = new EventScheduler<GameTimeProvider>();
var gameWorld = new GameTimeProvider();

// 3. Schedule a simple event
var futureTime = gameWorld.CurrentTime.AddSeconds(30);
var eventId = scheduler.ScheduleEvent(
    new ScheduledEvent<GameTimeProvider>.Builder()
        .SetScheduledTime(futureTime)
        .SetName("Player Spawn")
        .SetRunAction(world => Console.WriteLine("Player spawned!"))
        .Build()
);

Console.WriteLine($"Scheduled event with ID: {eventId}");

Advanced Event with Warnings

// Create an event with a 1-minute warning
var missionTime = gameWorld.CurrentTime.AddMinutes(5);
var missionEvent = new ScheduledEvent<GameTimeProvider>.Builder()
    .SetScheduledTime(missionTime)
    .SetName("Mission Start")
    .SetDescription("Assault the enemy base")
    .SetWarningBefore(TimeSpan.FromMinutes(1)) // Warn 1 minute before
    .SetRunAction(world => StartMission(world))
    .SetRunWarningAction(world => ShowMissionWarning(world))
    .Build();

// Schedule the event
scheduler.ScheduleEvent(missionEvent);

// Subscribe to execution notifications
scheduler.ScheduledEventRun += (sender, args) =>
{
    Console.WriteLine($"Event completed: {args.ScheduledEvent.Name}");
};

// Update the scheduler (call this regularly, e.g., in your game loop)
scheduler.Update(gameWorld);

Complex Time Provider Example

// Custom time provider for accelerated time scenarios
public class AcceleratedGameTime : IWorldDateTimeProvider
{
    private DateTime _startTime = DateTime.Now;
    public double TimeMultiplier { get; set; } = 1.0;

    public DateTime CurrentTime =>
        _startTime.AddSeconds((DateTime.Now - _startTime).TotalSeconds * TimeMultiplier);
}

// Use in fast-forward scenarios (e.g., time-lapse gameplay)
var acceleratedTime = new AcceleratedGameTime { TimeMultiplier = 10.0 };
var scheduler = new EventScheduler<AcceleratedGameTime>();

๐Ÿ“š API Reference

IEventScheduler<TWorld>

public interface IEventScheduler<TWorld> where TWorld : IWorldDateTimeProvider
{
    // Events
    event EventHandler<ScheduledEventRunEventArgs<TWorld>>? ScheduledEventRun;

    // Methods
    Guid ScheduleEvent(IScheduledEvent<TWorld> scheduledEvent);
    void RescheduleEvent(Guid scheduledEventId, DateTime newScheduledTime);
    IEnumerable<IScheduledEvent<TWorld>> GetScheduledEvents();
    IScheduledEvent<TWorld>? GetScheduledEvent(Guid scheduledEventId);
    bool CancelEvent(Guid scheduledEventId);
    void Update(TWorld world);
}

IScheduledEvent<TWorld>

public interface IScheduledEvent<TWorld>
{
    Guid Id { get; }
    string? Name { get; }
    string? Description { get; }
    DateTime ScheduledTime { get; }
    TimeSpan WarningBefore { get; }
    bool HasWarning { get; }
    bool IsWarningSent { get; }

    bool IsDue(TWorld dateTimeProvider);
    bool IsWarningDue(TWorld dateTimeProvider);
    void Run(TWorld world);
    void RunWarning(TWorld world);
}

Builder Pattern

var event = new ScheduledEvent<MyWorld>.Builder()
    .SetScheduledTime(DateTime.Now.AddHours(1))
    .SetName("Hourly Backup")
    .SetWarningBefore(TimeSpan.FromMinutes(5))
    .SetRunAction(world => PerformBackup(world))
    .SetRunWarningAction(world => NotifyUsers(world))
    .Build();

๐Ÿ—๏ธ Architecture

EventScheduler.sln
โ”œโ”€โ”€ EventScheduler.Abstractions/
โ”‚   โ”œโ”€โ”€ IEventScheduler.cs
โ”‚   โ”œโ”€โ”€ IScheduledEvent.cs
โ”‚   โ””โ”€โ”€ IWorldDateTimeProvider.cs    # Time abstraction
โ”œโ”€โ”€ EventScheduler/
โ”‚   โ”œโ”€โ”€ EventScheduler.cs           # Main scheduler implementation
โ”‚   โ””โ”€โ”€ ScheduledEvent.cs           # Event implementation with Builder
โ””โ”€โ”€ EventScheduler.Tests/           # Comprehensive test suite
    โ”œโ”€โ”€ EventSchedulerTests.cs      # 30 unit/integration tests
    โ””โ”€โ”€ Coverage/                   # 98.5% code coverage reports

Design Principles

  • Generic Programming: Works with any time provider implementation
  • Builder Pattern: Fluent, readable event construction
  • Observer Pattern: Event-driven notifications for execution
  • Chronological Ordering: O(n) insertion maintains time-based sequence
  • Abstraction Layer: Clean separation of interfaces and implementations

๐Ÿงช Testing

The library includes a comprehensive test suite with excellent coverage:

# Run all tests with coverage
.\test-suite.ps1

# Or run manually:
dotnet test --collect:"XPlat Code Coverage"

Test Results

  • โœ… 30 Tests - All passing
  • โœ… 98.5% Line Coverage
  • โœ… 100% Method Coverage
  • โœ… 90.4% Branch Coverage

Test categories include:

  • Unit tests for core scheduling logic
  • Integration tests for event lifecycle
  • Warning system validation
  • Edge case coverage
  • Time manipulation scenarios

๐Ÿš€ Use Cases

๐ŸŽฎ Game Development

// Level transition events
var levelEndEvent = new ScheduledEvent<GameWorld>.Builder()
    .SetScheduledTime(DateTime.Now.AddMinutes(30))
    .SetWarningBefore(TimeSpan.FromSeconds(30))
    .SetRunAction(world => LoadNextLevel(world))
    .SetRunWarningAction(world => ShowLevelEndingMessage(world))
    .Build();

๐Ÿค– IoT Applications

// Sensor maintenance scheduling
var maintenanceEvent = new ScheduledEvent<IoTDevice>.Builder()
    .SetScheduledTime(DateTime.Now.AddDays(30))
    .SetWarningBefore(TimeSpan.FromDays(1))
    .SetRunAction(device => PerformCalibration(device))
    .SetRunWarningAction(device => SendMaintenanceAlert(device))
    .Build();

๐Ÿญ Simulation Systems

// Production line events
var productionShift = new ScheduledEvent<Factory>.Builder()
    .SetScheduledTime(DateTime.Parse("6:00 AM").AddDays(1))
    .SetWarningBefore(TimeSpan.FromMinutes(15))
    .SetRunAction(factory => StartProductionLine(factory))
    .SetRunWarningAction(factory => AlertWorkers(factory))
    .Build();

๐Ÿ–ฅ๏ธ Server Applications

// Job scheduling system
var backupJob = new ScheduledEvent<Server>.Builder()
    .SetScheduledTime(DateTime.Now.Date.AddHours(2))
    .SetWarningBefore(TimeSpan.FromMinutes(10))
    .SetRunAction(server => ExecuteBackup(server))
    .SetRunWarningAction(server => PrepareBackupResources(server))
    .Build();

๐Ÿค Contributing

We welcome contributions! Please follow these steps:

Development Setup

# Clone and build
git clone https://github.com/yourusername/eventscheduler.git
cd eventscheduler
dotnet build EventScheduler.sln

# Run tests
.\test-suite.ps1

# View coverage report (opens in browser)
start coveragereport\index.html

Contribution Guidelines

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Test your changes thoroughly
  4. Commit your changes (git commit -m 'Add some amazing feature')
  5. Push to the branch (git push origin feature/amazing-feature)
  6. Open a Pull Request

Code Standards

  • Follow C# coding guidelines
  • Add comprehensive unit tests for new features
  • Maintain code coverage above 95%
  • Use meaningful commit messages
  • Update documentation for API changes

Testing Requirements

  • All new code must include unit tests
  • Integration tests for complex features
  • Code coverage must not decrease
  • All tests must pass on CI

๐Ÿ“„ License

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

MIT License

Copyright (c) 2025 EventScheduler Contributors

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

๐Ÿ“ž Support

  • ๐Ÿ“– Documentation: See this README and inline code comments
  • ๐Ÿ› Bug Reports: Open an issue with detailed reproduction steps
  • ๐Ÿ’ก Feature Requests: Open an issue with use case descriptions
  • ๐Ÿ’ฌ Discussions: GitHub Discussions for general questions

๐Ÿ™ Acknowledgments

  • Built with .NET Standard for maximum compatibility
  • Comprehensive test coverage using xUnit and Coverlet
  • Inspired by event scheduling needs in game development and simulation

EventScheduler - Precise timing, reliable execution, flexible warnings.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  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.  net9.0 was computed.  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. 
.NET Core netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.1 is compatible. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen 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.2 152 11/29/2025
1.0.1 128 11/29/2025
1.0.0 137 11/29/2025