static void RunInterval(MockTimerState ts) { IntervalHandler timer = new IntervalHandler(ts, ConsoleThreads); Console.WriteLine("initialized timer"); GC.KeepAlive(timer); Console.WriteLine("tell GC to ignore timer object"); List<GameMonitoringConfig> games = Games.Instance.GetMonitoredGames(); //one timer.OneMinute += new IntervalHandler.IntervalHandlerDelegate(MonitoringEvents.UserActivitycheck); timer.OneMinute += new IntervalHandler.IntervalHandlerDelegate(MonitoringEvents.HostingInstanceCheck); timer.OneMinute += new IntervalHandler.IntervalHandlerDelegate(MonitoringEvents.GameSessionActivityCheck); timer.OneMinute += new IntervalHandler.IntervalHandlerDelegate(MonitoringEvents.RunTransactionReport); //five timer.FiveMinutes += new IntervalHandler.IntervalHandlerDelegate(MonitoringEvents.OnInterval); //fifteen timer.FifteenMinutes += new IntervalHandler.IntervalHandlerDelegate(MonitoringEvents.OnInterval); //timer.FifteenMinutes += new IntervalHandler.IntervalHandlerDelegate(ProcessRetention); //thirty timer.ThirtyMinutes += new IntervalHandler.IntervalHandlerDelegate(MonitoringEvents.OnInterval); //one hour timer.SixtyMinutes += new IntervalHandler.IntervalHandlerDelegate(MonitoringEvents.OnInterval); timer.SixtyMinutes += new IntervalHandler.IntervalHandlerDelegate(MonitoringEvents.ScrapeUserData); //six hours timer.SixHours += new IntervalHandler.IntervalHandlerDelegate(MonitoringEvents.OnInterval); //twelve timer.TwelveHours += new IntervalHandler.IntervalHandlerDelegate(MonitoringEvents.OnInterval); //daily timer.TwentyFourHours += new IntervalHandler.IntervalHandlerDelegate(MonitoringEvents.OnInterval); timer.TwentyFourHours += new IntervalHandler.IntervalHandlerDelegate(MonitoringEvents.RunTransactionReport); timer.TwentyFourHours += new IntervalHandler.IntervalHandlerDelegate(MonitoringEvents.ProcessRetention); Console.WriteLine("set event callbacks"); timer.OnCheck += new IntervalHandler.OnCheckDelegate(StopInterval); //long timeToWait = 60000; long timeToWait = 1000; long WaitTillWholeMin = 0; //this is telling this guy to wait until the next whoe minute (:00 seconds) Console.WriteLine("Waiting till the next whole minute to start the Timer"); //run the time at what interval timer.run((long)timeToWait, WaitTillWholeMin, games); ///60 seconds // 1 minute == 60000 /// //Thread.Sleep(30000); }
public static void IntervalMenu() { Console.Clear(); Console.WriteLine(String.Format("Moniverse Manager : {0} : What What What, What would you do?", env)); Console.WriteLine(String.Format("Run a timer Interval?", env)); Console.WriteLine(String.Format(@"These intervals correspond to the intervals that fire in the playverse reader service")); Console.WriteLine(""); Console.WriteLine(String.Format("1. One Minute")); Console.WriteLine(String.Format("5. Five Minute")); Console.WriteLine(String.Format("15. Fifteen Minute")); Console.WriteLine(String.Format("30. Thirty Minute")); Console.WriteLine(String.Format("60. Sixty Minute")); Console.WriteLine(String.Format("360. Three Hundred Sixty (6 hours)")); Console.WriteLine(String.Format("720. Seven Hundred Twenty (12 hours)")); Console.WriteLine(String.Format("1440.Fourteen Hundered Fourty (24 hour)")); Console.WriteLine("0. Back"); string result = Console.ReadLine(); try { int r = 0; if(result != "" || result != "/r" || result != "/n"){ r = Convert.ToInt32(result); } int resultSwitch = r; try { MockTimerState ts = new MockTimerState(r); RunInterval(ts); DisplayMenu(); } catch (Exception) { Console.WriteLine("Incorrect Input"); IntervalMenu(); } IntervalMenu(); } catch (Exception) { Console.WriteLine("INvalid Input"); } }