private void OnServerUpdated(ServerInfo serverInfo) { //The server doesn't have performance data yet if (serverInfo == null) return; this.AvailableCompletionPortThreads = serverInfo.AvailableCompletionPortThreads; this.AvailableWorkingThreads = serverInfo.AvailableWorkingThreads; this.CpuUsage = serverInfo.CpuUsage; this.MaxCompletionPortThreads = serverInfo.MaxCompletionPortThreads; this.MaxWorkingThreads = serverInfo.MaxWorkingThreads; this.PhysicalMemoryUsage = serverInfo.PhysicalMemoryUsage; this.TotalThreadCount = serverInfo.TotalThreadCount; var newInstanceFound = false; foreach (var instance in serverInfo.Instances) { var newFound = false; var targetInstance = Instances.FirstOrDefault(i => i.Name.Equals(instance.Name, StringComparison.OrdinalIgnoreCase)); if (targetInstance == null) { targetInstance = new InstanceViewModel(this, instance.Name); newFound = true; newInstanceFound = true; } targetInstance.CurrentConnectionCount = instance.CurrentConnectionCount; targetInstance.IsRunning = instance.IsRunning; targetInstance.Listener = instance.Listener; targetInstance.MaxConnectionCount = instance.MaxConnectionCount; targetInstance.RequestHandlingSpeed = instance.RequestHandlingSpeed; targetInstance.StartedTime = instance.StartedTime; if (newFound || (targetInstance.State == InstanceState.NotConnected || targetInstance.State == InstanceState.Connecting)) { targetInstance.State = targetInstance.IsRunning ? InstanceState.Running : InstanceState.NotStarted; } if (newFound) { Instances.Add(targetInstance); } } if (newInstanceFound) Messenger.Default.Send<IEnumerable<InstanceViewModel>>(null); }