Database Reference
In-Depth Information
We can delay the processing of a message or schedule a task with NSB. This is done in
support of the NServiceBus.Schedule function where we can schedule actions or
send messages based on time. Here, we are showing the support of scheduling a task to be
performed after a minute:
namespace MyServer.Scheduling
{
public class ScheduleATaskHandler :
IHandleMessages<ScheduleATask>
{
private readonly IBus bus;
public ScheduleATaskHandler(IBus bus)
{
this.bus = bus;
}
public void Handle(ScheduleATask message)
{
Console.WriteLine("Scheduling a task to be
executed every 1 minute");
Schedule.Every(TimeSpan.FromMinutes(1)).Action(() =>
bus.SendLocal(new ScheduledTaskExecuted()));
}
}
}
Tip
Downloading the example code
Search WWH ::




Custom Search