private void tick(object state)
        {
            TelemetryStatics.ExecuteBlockWithStandardExceptionHandling(
                () => {
                // We need to schedule the next tick even if there is an exception thrown in this one. Use try-finally instead of CallEveryMethod so we don't lose
                // exception stack traces.
                try {
                    var currentInstant = SystemClock.Instance.GetCurrentInstant();
                    var interval       = new TickInterval(new Interval(lastTickInstant, currentInstant));
                    lastTickInstant    = currentInstant;

                    if (ConfigurationStatics.IsLiveInstallation && interval.FitsPattern(OperationRecurrencePattern.CreateDaily(0, 0)))
                    {
                        EmailStatics.SendHealthCheckEmail(WindowsServiceMethods.GetServiceInstalledName(service));
                    }

                    service.Tick(interval);
                }
                finally {
                    try {
                        timer.Change(tickInterval, Timeout.Infinite);
                    }
                    catch (ObjectDisposedException) {
                        // This should not be necessary with the Timer.Dispose overload we are using, but see http://stackoverflow.com/q/12354883/35349.
                    }
                }
            });
        }
Example #2
0
        private void tick(object state)
        {
            TelemetryStatics.ExecuteBlockWithStandardExceptionHandling(
                () => {
                // We need to schedule the next tick even if there is an exception thrown in this one. Use try-finally instead of CallEveryMethod so we don't lose
                // exception stack traces.
                try {
                    var currentInstant = SystemClock.Instance.GetCurrentInstant();
                    var interval       = new TickInterval(new Interval(lastTickInstant, currentInstant));
                    lastTickInstant    = currentInstant;

                    service.Tick(interval);
                }
                finally {
                    try {
                        timer.Change(tickInterval, Timeout.Infinite);
                    }
                    catch (ObjectDisposedException) {
                        // This should not be necessary with the Timer.Dispose overload we are using, but see http://stackoverflow.com/q/12354883/35349.
                    }
                }
            });
        }