Agent & Automation Guide¶
This page is a compact entry point for assistants, scripts, and contributors who need the main NCronJob concepts quickly.
Primary public entry points¶
Registration¶
AddNCronJob(...)registers the scheduler and typed jobsAddNCronJob(Delegate jobDelegate, string cronExpression, TimeZoneInfo? timeZoneInfo = null)registers a delegate-based recurring jobAddNCronJob(Delegate jobDelegate, string cronExpression, TimeZoneInfo? timeZoneInfo, string jobName)registers a named delegate-based recurring job
Startup behavior¶
UseNCronJobAsync(IHost)andUseNCronJob(IHost)must be called when any job usesRunAtStartup(...)- For regular recurring jobs and instant jobs, these calls are optional
Job authoring¶
IJobis the main typed-job abstractionIJobExecutionContextprovides the parameter, attempt count, correlation id, and execution metadata- The minimal API style resolves services directly from the delegate signature
Runtime interaction¶
IInstantJobRegistrytriggers instant and delayed jobsIRuntimeJobRegistryadds, removes, enables, disables, and updates named recurring jobs at runtime
Recommended reading order for agents¶
High-signal behavioral notes¶
- Use named jobs when the same job type is registered multiple times or when runtime management is needed
RunInstantJob<TJob>()can become ambiguous if multiple registrations exist for the same job type; preferRunInstantJob("job-name")in that case- Parameters are passed by reference, not serialized, so mutation after enqueueing can affect execution
- Forced instant jobs (
ForceRunInstantJob/ForceRunScheduledJob) bypass queue and concurrency protection - After
Build(), callUseNCronJobAsync()orUseNCronJob()wheneverRunAtStartup(...)is used; see Running Startup Jobs
Repository sample map¶
sample/MinimalSample: minimal recurring delegate jobsample/NCronJobSample: typed jobs, notifications, retries, concurrency, instant job endpointssample/RunOnceSample: startup job flow
Preferred source of truth¶
When an example and prose disagree, prefer:
- Public API and XML docs in
src/NCronJob - The sample applications in
sample/* - The feature pages in
docs/*
Machine-friendly documentation files¶
llms.txtprovides a compact discovery index- llms-full.md provides a compact Markdown reference for retrieval and prompting