Beispiel #1
0
        /// <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));
        }
Beispiel #2
0
        /// <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();
            }
        }
Beispiel #3
0
 public void Remove(Engine engine)
 {
     db.Engines.Remove(engine);
 }
Beispiel #4
0
 public void Add(Engine engine)
 {
     db.Engines.Add(engine);
 }