I'd like your opinion on something. I have the following class:
public class ApplicationClock
{
void tick(object _)
{
lock (tickLock)
{
try
{
MessageBroker.Publisher.Publish(new Tick());
}
catch (Exception e)
{
this.Logger().Error("Application clock tick error", e);
//who knows why this happened, let's try and restart
if (ticker != null) ticker.Dispose();
Start();
}
}
}
readonly Object tickLock = new Object();
Timer ticker = null;
public ApplicationClock Start()
{
ticker = new Timer(tick, null, 0, 60*1000);
return this;
}
}
launched from the MvcApplication bootstrapper
...
ApplicationClock clock;
protected void Application_Start()
{
//...
clock = new ApplicationClock().Start();
}
I realize that a service and some sort of inter-process communication (whether windows inter-process communication, HTTP, or something else) is more standard and reliable but I have a frequently changing team and don't want to add another step that is necessary to run the app.
This seems to work but I've only launched it in a dev scenario. Am I missing anything that would cause problems in production?
That's a System.Threading.Timer by the way.