public CityConnections(LotServerConfiguration config, IKernel kernel) { Config = config; try { CpuCounter = new PerformanceCounter(); CpuCounter.CategoryName = "Processor"; CpuCounter.CounterName = "% Processor Time"; CpuCounter.InstanceName = "_Total"; if (PerformanceCounterCategory.Exists("Processor")) { var firstValue = CpuCounter.NextValue(); } } catch { LOG.Info("Performance counters are not supported on this platform, running without."); } Connections = new Dictionary <LotServerConfigurationCity, CityConnection>(); foreach (var city in config.Cities) { var connection = new CityConnection(kernel, city, config); Connections.Add(city, connection); connection.OnDisconnected += Connection_OnDisconnected; } }
void Connection_OnDisconnected(CityConnection connection) { if (OnCityDisconnected != null) { OnCityDisconnected(connection); } }
public CityConnections(LotServerConfiguration config, IKernel kernel) { Config = config; CpuCounter = new PerformanceCounter(); CpuCounter.CategoryName = "Processor"; CpuCounter.CounterName = "% Processor Time"; CpuCounter.InstanceName = "_Total"; if (PerformanceCounterCategory.Exists("Processor")) { var firstValue = CpuCounter.NextValue(); } Connections = new Dictionary <LotServerConfigurationCity, CityConnection>(); foreach (var city in config.Cities) { var connection = new CityConnection(kernel, city, config); Connections.Add(city, connection); connection.OnDisconnected += Connection_OnDisconnected; } }