Skip to content

Commit

Permalink
docs: Update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
linkdotnet committed Mar 17, 2024
1 parent 87323b8 commit 9f7772b
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,22 @@ builder.Services.AddCronJob<PrintHelloWorld>(options =>
```

4. Run your application and see the magic happen

## Triggering a instant job
If the need arises and you want to trigger a job instantly, you can do so:
```csharp
public class MyService
{
private readonly IInstantJobRegistry jobRegistry;

public MyService(IInstantJobRegistry jobRegistry)
{
this.jobRegistry = jobRegistry;
}

public void MyMethod()
{
jobRegistry.AddInstantJob<MyJob>("I am an optional parameter");
}
}
```
2 changes: 1 addition & 1 deletion sample/NCronJobSample/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
{
instantJobRegistry.AddInstantJob<PrintHelloWorld>();
})
.WithName("GetWeatherForecast")
.WithName("TriggerInstantJob")
.WithOpenApi();

app.Run();

0 comments on commit 9f7772b

Please sign in to comment.