// =========================================================== // Getter & Setter // =========================================================== // =========================================================== // Methods for/from SuperClass/Interfaces // =========================================================== // =========================================================== // Methods // =========================================================== public static void CreateThrottleTimer(Stopwatch pTimer, int pFromTime, int pToTime, string pTimerStringName) { TimerStringName = pTimerStringName; // Generate a random number from a given set of values var randNumber = RandomNumber.GenerateRandomInt(pFromTime, pToTime); foreach (var t in ThrottleTimers.Where(t => t.TimerName == TimerStringName)) { t.Time = randNumber; } // Check a throttle timer using our currently received timer and the random number CheckThrottleTimer(pTimer, randNumber, TimerStringName); }
// =========================================================== // Inner and Anonymous Classes // =========================================================== private static void FormatAndShowTimer(string pTimerStringName) { // Create a new timer if last one has expired or we didn't have one if (!WaitTimerCreated) { foreach (var t in ThrottleTimers.Where(t => t.TimerName == pTimerStringName)) { WaitTimerCreated = true; // Set up a new timer based on the amount of milliseconds in our current timer WaitTimer = new WaitTimer(new TimeSpan(0, 0, 0, 0, t.Time)); // Build the string with the proper format WaitTimerAsString = BuildTimeAsString(WaitTimer.WaitTime); WaitTimer.Reset(); } } OutputMessage(pTimerStringName); }