示例#1
0
        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;
            }
        }
示例#2
0
 void Connection_OnDisconnected(CityConnection connection)
 {
     if (OnCityDisconnected != null)
     {
         OnCityDisconnected(connection);
     }
 }
示例#3
0
        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;
            }
        }