/// <summary> /// Constructor and setup of background processes /// </summary> public BackgroundProcess() { HostingEnvironment.RegisterObject(this); db = new Repository(); engine = db.Engines.FirstOrDefault(e => e.HostName == System.Environment.MachineName); gameLoop = new GameLoop(); monitorLoop = new MonitorLoop(); sweepLoop = new SweepLoop(); Setup(); GameTimer = new Timer(OnGameTimerElapsed, null, TimeSpan.FromSeconds(0), TimeSpan.FromMilliseconds(engine.GameLoopInterval)); MonitorTimer = new Timer(OnMonitorTimerElapsed, null, TimeSpan.FromSeconds(0), TimeSpan.FromMilliseconds(engine.MonitorLoopInterval)); SweepTimer = new Timer(OnSweepTimerElapsed, null, TimeSpan.FromSeconds(0), TimeSpan.FromMilliseconds(engine.SweepLoopInterval)); }
/// <summary> /// Setup of engine object /// </summary> private void Setup() { if (engine == null) { // create new engine model engine = new Engine { HostName = System.Environment.MachineName, TimeStarted = DateTime.Now, AppPath = HttpRuntime.AppDomainAppVirtualPath, Version = typeof(IOnEx.Hubs.IOnExHub).Assembly.GetName().Version.ToString(), GameLoop = true, GameLoopInterval = 1000, MonitorLoop = true, MonitorLoopInterval = 2000, SweepLoop = true, SweepLoopInterval = 4000 }; db.Add(engine); db.CommitChanges(); } else { // update existing engine model engine.HostName = System.Environment.MachineName; engine.AppPath = HttpRuntime.AppDomainAppVirtualPath; engine.TimeStarted = DateTime.Now; engine.Version = typeof(IOnEx.Hubs.IOnExHub).Assembly.GetName().Version.ToString(); db.CommitChanges(); } }
public void Remove(Engine engine) { db.Engines.Remove(engine); }
public void Add(Engine engine) { db.Engines.Add(engine); }