AI agents: use the documentation index at llms.txt to locate machine-readable pages. This section is indexed by https://docs.particular.net/samples/llms.txt. The markdown version of this page is served as plain text. An MCP server at /mcp serves the same content via the search_docs and read_doc tools; it is read-only and needs no credentials. Markdown versions of documentation pages are available by appending .md to the page URL. Directory URLs use index.md. They are served as text/plain because some retrieval backends reject text/markdown.

Scheduling with Timers

Component:
NServiceBus
NuGet Package:
NServiceBus 10.x

This sample illustrates the use of a .NET Timer to trigger scheduled tasks. To leverage the benefits of NServiceBus retries and consistency of outgoing messages with the transport transaction, the tasks are implemented as regular message handlers. This also gives full traceability of the invoked tasks in platform tools like ServicePulse.

var interval = TimeSpan.FromSeconds(5);

var timer = new Timer(async state =>
{
    try
    {
        await messageSession.SendLocal(new MyScheduledTask());

        logger.LogInformation("{Task} scheduled", nameof(MyScheduledTask));
    }
    catch (Exception ex)
    {
        logger.LogError(ex, nameof(MyScheduledTask) + " could not be scheduled");
    }
}, null, interval, interval);

Related Articles

  • Scheduling
    Schedule a task or an action/lambda, to be executed repeatedly at a given interval.