Apr 17 2023


"ConnectionStrings": { "DefaultConnection": "Server=localhost;Database=Hangfire;Trusted_Connection=True" }
builder.Services.AddHangfire(x => { x.UseSqlServerStorage(builder.Configuration .GetConnectionString("DefaultConnection")); })
builder.Services.AddHangfireServer();
app.UseHangfireDashboard();
builder.Services.AddHostedService<SomeService>();

public interface IJobsService { void FireAndForgetJob(); void DelayedJob(); void ReccuringJob(); void Continuation(); void BatchJob(); }
[HttpGet("FireAndForgetJob")] public ActionResult CreateFireAndForgetJob() { _jobClient.Enqueue(() => _jobsService.FireAndForgetJob()); return Ok(); }
[HttpGet("DelayedJob")] public ActionResult CreateDelayedJob() { _jobClient.Schedule(() => _jobsService.DelayedJob(), TimeSpan.FromSeconds(60)); return Ok(); }
[HttpGet("ContinuationJob")] public ActionResult CreateContinuationJob() { var parentJobId = _jobClient.Enqueue(() => _jobsService.FireAndForgetJob()); _jobClient.ContinueJobWith(parentJobId, () => _jobsService.Continuation()); return Ok(); }
[HttpGet("ReccuringJob")] public ActionResult CreateReccuringJob() { _recurringJobManager.AddOrUpdate("jobId", () => _jobsService.ReccuringJob(), Cron.Daily); return Ok(); }
var batchId = BatchJob.StartNew(x => { x.Enqueue(() => Console.WriteLine("Job 1")); x.Enqueue(() => Console.WriteLine("Job 2")); })
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