I have a high-level architecture question. I am building an MVC application that needs to do the following related tasks:
- Send alerts when certain criteria are met
- implement business rules on incoming data
For example, a user may input a task assigned to herself and set it to be due in three hours. Based on a business rule, when it is within one hour of its due time, the status would change from "pending" to "urgent."
This means that once per time period N, something needs to check the time of all pending tasks to see if they've entered the "urgent" threshold. Up to this point, I've only performed tasks like this using Windows Task Scheduler. (Create a batch file or EXE, have it run once every fifteen minutes.) I've been trying to suss out how the pros do it.
I'm under the impression that the preferred solution is to run a service to implement business rules. Here's what I don't understand: if I'm not using a utility like task scheduler, am I basically just running an infinite loop in one thread of my application that queries the service?
do
{
myObject = myService.query();
if (myObject.dueDate < Now() + 1 hour)
{
myObject.status = urgent
//Update db
//update view
myService.fireAlert(myObject);
}
Thread.Sleep(60000);
}
This may be a broad, academic question. To be more specific, I'm coming at this with no knowledge of Windows Services. I think that's the direction I need to go, as I haven't really seen anything in the way of alternative ways to schedule code to run. Are there other possibilities?
For anyone who knows about SignalR, does that apply here?