Appearance
Job Types
GrydJobs supports four job execution patterns, all through the IJobScheduler interface.
Fire-and-Forget
Jobs that execute immediately in the background. The caller does not wait for completion.
csharp
// Strongly-typed (recommended)
await scheduler.EnqueueAsync<SendEmailJob, SendEmailArgs>(
new SendEmailArgs("user@example.com", "Subject", "Body"));
// Dynamic (runtime type resolution)
await scheduler.EnqueueAsync(
"MyApp.Jobs.SendEmailJob, MyApp",
serializedArgs: """{"To":"user@example.com"}""",
argsTypeName: "MyApp.Jobs.SendEmailArgs, MyApp");Delayed Jobs
Jobs that execute after a specified delay or at a specific time.
csharp
// After a delay
await scheduler.ScheduleAsync<ReminderJob, ReminderArgs>(
new ReminderArgs(userId, "Don't forget!"),
TimeSpan.FromHours(24));
// At a specific time
await scheduler.ScheduleAsync<ReportJob, ReportArgs>(
new ReportArgs(reportId),
new DateTimeOffset(2026, 3, 1, 9, 0, 0, TimeSpan.Zero));Recurring Jobs
Jobs that execute on a cron schedule. Implement IRecurringJob:
csharp
public class DatabaseCleanupJob : IRecurringJob
{
public string JobId => "db-cleanup";
public string CronExpression => "0 2 * * *"; // Daily at 2:00 AM
public string Queue => "low";
private readonly ICleanupService _cleanup;
public DatabaseCleanupJob(ICleanupService cleanup)
=> _cleanup = cleanup;
public async Task ExecuteAsync(
JobExecutionContext context,
CancellationToken cancellationToken)
{
await _cleanup.PurgeOldRecordsAsync(
TimeSpan.FromDays(90), cancellationToken);
}
}Auto-Registration
When AutoRegisterRecurringJobs = true (default), GrydJobs scans JobAssemblies at startup and automatically registers all IRecurringJob implementations.
Manual Registration
csharp
// Via IJobScheduler (strongly-typed)
await scheduler.AddOrUpdateRecurringAsync<DatabaseCleanupJob>(
"db-cleanup",
"0 2 * * *",
TimeZoneInfo.FindSystemTimeZoneById("America/Sao_Paulo"),
queue: "low");
// Via API
// POST /api/v1/recurring-jobs
// { "jobId": "db-cleanup", "jobTypeName": "...", "cronExpression": "0 2 * * *" }Pause / Resume / Trigger
csharp
// Via API endpoints
// POST /api/v1/recurring-jobs/{id}/pause
// POST /api/v1/recurring-jobs/{id}/resume
// POST /api/v1/recurring-jobs/{id}/trigger (immediate execution)Continuation Jobs
Jobs that execute after a parent job completes successfully.
csharp
// First job
var parentJobId = await scheduler.EnqueueAsync<GenerateReportJob, ReportArgs>(
new ReportArgs(reportId));
// Runs after parent completes
await scheduler.ContinueWithAsync<SendReportEmailJob, SendReportArgs>(
parentJobId,
new SendReportArgs(reportId, recipientEmail));Cron Expression Reference
GrydJobs uses 5-part cron expressions (minute, hour, day-of-month, month, day-of-week):
| Expression | Schedule |
|---|---|
* * * * * | Every minute |
0 * * * * | Every hour |
0 0 * * * | Daily at midnight |
0 0 * * 1 | Every Monday |
0 9 1 * * | First day of month at 9:00 |
*/5 * * * * | Every 5 minutes |
0 2 * * * | Daily at 2:00 AM |
0 0 1 1 * | January 1st at midnight |