Feb 02 2026
public class SendDailyReportsEmailJob : IInvocable { public Task Invoke() { Console.WriteLine("Sending daily report email..."); return Task.CompletedTask; } }
builder.Services.AddScheduler(); builder.Services.AddTransient<SendDailyReportsEmailJob>();
app.Services.UseScheduler(scheduler => { scheduler .Schedule<SendDailyReportsEmailJob>() .DailyAtHour(6); // Every day at 6 AM });
public class ProcessWebhook : IInvocable { public Task Invoke() { Console.WriteLine("Webhook processed in background."); return Task.CompletedTask; } }
var dispatcher = app.Services.GetService<IDispatcher>(); await dispatcher.EnqueueAsync<ProcessWebhook>();
public record OrderPlacedEvent(int OrderId);
public class SendThankYouEmail : IListener<OrderPlacedEvent> { public Task HandleAsync(OrderPlacedEvent e) { Console.WriteLine($"Thank you email sent for order {e.OrderId}."); return Task.CompletedTask; } }
await eventDispatcher.BroadcastAsync(new OrderPlacedEvent(123));
public class WelcomeMailable : Mailable<User> { public override void Build() { To(Model.Email) .Subject("Welcome to our platform!") .View("Emails.Welcome", Model); } }
await mailer.SendAsync(new WelcomeMailable(user));
public class WelcomeMailable : Mailable<User> { public override void Build() { To(Model.Email) .Subject("Welcome to our platform!") .View("Emails.Welcome", Model); } }
await mailer.SendAsync(new WelcomeMailable(user));
var data = cache.GetOrAdd("top-products", () => { return FetchTopProducts(); }, TimeSpan.FromMinutes(15));
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)); } }
scheduler.Schedule<GenerateAndSendReportJob>() .DailyAtHour(8);
1. Design Patterns that Deliver
This isn’t just another design patterns book. Dive into real-world examples and practical solutions to real problems in real applications.Check out it here.
Go-to resource for understanding the core concepts of design patterns without the overwhelming complexity. In this concise and affordable ebook, I've distilled the essence of design patterns into an easy-to-digest format. It is a Beginner level. Check out it here.
Every Monday morning, I share 1 actionable tip on C#, .NET & Arcitecture topic, that you can use right away.
Join 18,000+ subscribers to improve your .NET Knowledge.
Subscribe to the TheCodeMan.net and be among the 18,000+ subscribers gaining practical tips and resources to enhance your .NET expertise.
Powered by EmailOctopus