/// <summary>
        /// Creates a ServiceBase adapter. Generated code use only.
        /// </summary>
        public ServiceBaseAdapter(WindowsServiceBase service)
        {
            ServiceName = WindowsServiceMethods.GetServiceInstalledName(service);
            AutoLog     = false;

            this.service = service;
        }
        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.
                    }
                }
            });
        }
        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 now = DateTime.Now;
                    if (ConfigurationStatics.IsLiveInstallation && !ConfigurationStatics.MachineIsStandbyServer &&
                        new[] { lastHealthCheckDateAndTime, now }.Any(dt => dt.Date.IsBetweenDateTimes(lastHealthCheckDateAndTime, now)))
                    {
                        EmailStatics.SendHealthCheckEmail(WindowsServiceMethods.GetServiceInstalledName(service));
                    }
                    lastHealthCheckDateAndTime = now;

                    service.Tick();
                }
                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.
                    }
                }
            });
        }