internal void Refresh() { using (RegistryKey registryKey = Registry.LocalMachine.OpenSubKey("SOFTWARE\\Microsoft\\ExchangeServer\\v15\\LatencyDetectionOptions")) { if (registryKey == null) { this.latencyDetectionEnabled = false; this.WatsonThrottle = TimeSpan.FromMinutes(10.0); this.InitialWait = TimeSpan.FromMinutes(3.0); this.RefreshOptionsInterval = TimeSpan.FromSeconds(30.0); this.BacklogRetirementAge = TimeSpan.FromMinutes(10.0); this.MaximumBacklogSize = 32U; this.EnableLatencyEventLogging = PerformanceReportingOptions.IsLatencyEventLoggingEnabled(); } else { this.latencyDetectionEnabled = PerformanceReportingOptions.GetRegistryBoolean(registryKey, "Enabled", false); this.WatsonThrottle = TimeSpan.FromMinutes(PerformanceReportingOptions.GetRegistryUInt32(registryKey, "WatsonThrottleMinutes", 10U, 10U)); this.InitialWait = TimeSpan.FromMinutes(PerformanceReportingOptions.GetRegistryUInt32(registryKey, "InitialWaitMinutes", 3U, 0U, 120U)); this.RefreshOptionsInterval = TimeSpan.FromSeconds(PerformanceReportingOptions.GetRegistryUInt32(registryKey, "RefreshOptionsIntervalSeconds", 30U, 30U, 3600U)); this.BacklogRetirementAge = TimeSpan.FromMinutes(PerformanceReportingOptions.GetRegistryUInt32(registryKey, "BacklogRetirementAgeMinutes", 10U, 1U, 480U)); this.MaximumBacklogSize = PerformanceReportingOptions.GetRegistryUInt32(registryKey, "BacklogSizeLimit", 32U, 0U, 256U); this.EnableLatencyEventLogging = PerformanceReportingOptions.GetRegistryBoolean(registryKey, "EnableLatencyEventLogging", false); } lock (this.refreshLockObject) { this.nextRefresh = DateTime.UtcNow + this.RefreshOptionsInterval; } } }
void IThresholdInitializer.SetThresholdFromConfiguration(LatencyDetectionLocation location, LoggingType type) { TimeSpan threshold = location.DefaultThreshold; if (LoggingType.WindowsErrorReporting == type) { using (RegistryKey registryKey = Registry.LocalMachine.OpenSubKey("SOFTWARE\\Microsoft\\ExchangeServer\\v15\\LatencyDetectionOptions")) { if (registryKey != null) { uint registryUInt = PerformanceReportingOptions.GetRegistryUInt32(registryKey, location.Identity + "ThresholdMilliseconds", PerformanceReportingOptions.GetTotalMilliseconds(location.DefaultThreshold), PerformanceReportingOptions.GetTotalMilliseconds(location.MinimumThreshold)); threshold = TimeSpan.FromMilliseconds(registryUInt); } } } location.SetThreshold(type, threshold); }
private static uint GetRegistryUInt32(RegistryKey key, string name, uint defaultValue, uint minimum) { return(PerformanceReportingOptions.GetRegistryUInt32(key, name, defaultValue, minimum, 2147483647U)); }