SimpleEventScheduler 1.0.2
dotnet add package SimpleEventScheduler --version 1.0.2
NuGet\Install-Package SimpleEventScheduler -Version 1.0.2
<PackageReference Include="SimpleEventScheduler" Version="1.0.2" />
<PackageVersion Include="SimpleEventScheduler" Version="1.0.2" />
<PackageReference Include="SimpleEventScheduler" />
paket add SimpleEventScheduler --version 1.0.2
#r "nuget: SimpleEventScheduler, 1.0.2"
#:package SimpleEventScheduler@1.0.2
#addin nuget:?package=SimpleEventScheduler&version=1.0.2
#tool nuget:?package=SimpleEventScheduler&version=1.0.2
EventScheduler
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
IWorldDateTimeProviderimplementation - ๐ฆ 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
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Test your changes thoroughly
- Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - 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 | Versions 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. |
-
.NETStandard 2.1
- SimpleEventScheduler.Abstractions (>= 1.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.