🔥 Pragmatic .NET Code Rules Course is on Presale - 40% off!BUY NOW

Job Scheduling with Coravel

Feb 02 2026

This issue is self-sponsored. By supporting my work and purchasing my products, you directly help me keep this newsletter free and continue creating high-quality, practical .NET content for the community. 

Thank you for the support 🙌  

P.S. I’m currently building a new course, Pragmatic .NET Code Rules, focused on creating a predictable, consistent, and self-maintaining .NET codebase using .editorconfig, analyzers, Visual Studio code cleanup, and CI enforcement.

The course is available for pre-sale until the official release, with early-bird pricing for early adopters. You can find all the details here.

Background

Coravel is a lightweight open-source library that adds background job scheduling, queuing, caching, mailing, and event broadcasting to your .NET apps - all without requiring a separate infrastructure.

If you've ever wanted to schedule background jobs, queue tasks, send emails, or cache data in your .NET applications without the complexity of setting up external services like Hangfire, Redis, or Quartz.NET - Coravel is your answer.

Inspired by Laravel (PHP), Coravel brings elegant syntax and powerful background features to .NET with zero configuration. It's the perfect tool for developers who want simplicity without sacrificing power.

Key Benefits:

• No database or message broker required • Perfect for small to medium apps • Fully integrates with ASP.NET Core dependency injection • Clean and readable syntax Let's see what you can do with Coravel.

Task Scheduling

You can run jobs like cleaning logs, syncing files, or sending emails on a schedule with Coravel's scheduler. Create job:

C#
public class SendDailyReportsEmailJob : IInvocable{ public Task Invoke() { Console.WriteLine("Sending daily report email..."); return Task.CompletedTask; }}

Register it:

C#
builder.Services.AddScheduler();builder.Services.AddTransient<SendDailyReportsEmailJob>();

Schedule it:

C#
app.Services.UseScheduler(scheduler =>{ scheduler .Schedule<SendDailyReportsEmailJob>() .DailyAtHour(6); // Every day at 6 AM});

You can also use: • .Hourly() • .EveryMinute() • .Weekly() • .Cron("/5 *") for advanced control

Queued Background Jobs

You can avoid blocking the main thread for tasks like sending emails or processing files. Create an Invocable Job:

C#
public class ProcessWebhook : IInvocable{ public Task Invoke() { Console.WriteLine("Webhook processed in background."); return Task.CompletedTask; }}

Queue it:

C#
var dispatcher = app.Services.GetService<IDispatcher>();await dispatcher.EnqueueAsync<ProcessWebhook>();

In-memory only: jobs are lost if the app restarts. Ideal for non-critical tasks.

Event Broadcasting

Coravel's event system enables decoupled communication between services in the same app. Define an Event:

C#
public record OrderPlacedEvent(int OrderId);

Create a Listener:

C#
public class SendThankYouEmail : IListener<OrderPlacedEvent>{ public Task HandleAsync(OrderPlacedEvent e) { Console.WriteLine($"Thank you email sent for order {e.OrderId}."); return Task.CompletedTask; }}

Use it:

C#
await eventDispatcher.BroadcastAsync(new OrderPlacedEvent(123));

Mailing with Razor Templates

Send beautiful, templated emails using Razor views. Define a Mailable:

C#
public class WelcomeMailable : Mailable<User>{ public override void Build() { To(Model.Email) .Subject("Welcome to our platform!") .View("Emails.Welcome", Model); }}

Send it:

C#
await mailer.SendAsync(new WelcomeMailable(user));

Supports view rendering from Razor Class Libraries or .cshtml files.

Mailing with Razor Templates

Send beautiful, templated emails using Razor views. Define a Mailable:

C#
public class WelcomeMailable : Mailable<User>{ public override void Build() { To(Model.Email) .Subject("Welcome to our platform!") .View("Emails.Welcome", Model); }}

Send it:

C#
await mailer.SendAsync(new WelcomeMailable(user));

Supports view rendering from Razor Class Libraries or .cshtml files.

Simple Caching

Built-in memory caching to store frequently used data. Store and Retrieve from Cache:

C#
var data = cache.GetOrAdd("top-products", () =>{ return FetchTopProducts();}, TimeSpan.FromMinutes(15));

No extra configuration or Redis needed.

Real-World Example: Report Generator

Imagine an internal admin dashboard for a SaaS platform. You want to:

• Send a daily email with usage reports to the admin • Cache report data for 30 minutes • Queue email sending in background • Use events when reports are generated

With Coravel: Store and Retrieve from Cache:

C#
public class GenerateAndSendReportJob : IInvocable{ private readonly ICache _cache; private readonly IMailer _mailer;  public GenerateAndSendReportJob(ICache cache, IMailer mailer) { _cache = cache; _mailer = mailer; }  public async Task Invoke() { var report = _cache.GetOrAdd("daily-report", () => GenerateReport(), TimeSpan.FromMinutes(30)); await _mailer.SendAsync(new ReportMailable(report)); }}

Schedule it:

C#
scheduler.Schedule<GenerateAndSendReportJob>() .DailyAtHour(8);

For heavier workloads, see Background Jobs with Hangfire. For built-in solutions, check Background Tasks in .NET 8.

Wrapping Up

Coravel proves that powerful background tasking in .NET doesn't need to be complex.

It lets you focus on business logic instead of infrastructure, giving you everything you need to build responsive and maintainable apps - fast.

Whether you're building an admin dashboard, a SaaS backend, or a microservice with lightweight needs, Coravel is a sharp and elegant tool to keep in your arsenal.

You can add it through NuGet. Here is the Coravel repo.

That's all from me today.

P.S. Follow me on YouTube.

About the Author

Stefan Djokic is a Microsoft MVP and senior .NET engineer with extensive experience designing enterprise-grade systems and teaching architectural best practices.

There are 3 ways I can help you:

1. Pragmatic .NET Code Rules Course

Stop arguing about code style. In this course you get a production-proven setup with analyzers, CI quality gates, and architecture tests — the exact system I use in real projects. Join here.

Not sure yet? Grab the free Starter Kit — a drop-in setup with the essentials from Module 01.

2. Design Patterns Ebooks

Design Patterns that Deliver — Solve real problems with 5 battle-tested patterns (Builder, Decorator, Strategy, Adapter, Mediator) using practical, real-world examples. Trusted by 650+ developers.

Just getting started? Design Patterns Simplified covers 10 essential patterns in a beginner-friendly, 30-page guide for just $9.95.

3. Join 20,000+ subscribers

Every Monday morning, I share 1 actionable tip on C#, .NET & Architecture that you can use right away. Join here.

Join 20,000+ subscribers who mass-improve their .NET skills with actionable tips on C#, Architecture & Best Practices.

Subscribe to
TheCodeMan.net

Subscribe to the TheCodeMan.net and be among the 20,000+ subscribers gaining practical tips and resources to enhance your .NET expertise.