Can someone review my timer class that runs some code every second, please? The void
it's calling (runCode
) is just a void with some code in it.
using Reality.Game.Sessions;
using System;
using System.Threading;
namespace Reality.Game.Misc
{
public static class UserTimer
{
public static void Initialize()
{
/* Lets rev this bad boy up... */
Timer timer = new Timer(callback, "Some state", TimeSpan.FromSeconds(1), TimeSpan.FromSeconds(1));
}
private static void callback(object state)
{
foreach (Session s in SessionManager.Sessions.Values)
{
if (s != null && s.Authenticated && !s.Stopped)
{
workTimer(s);
}
}
}
private static void workTimer(Session s)
{
JobCacheWorker.runCode(s);
}
}
}