コード例 #1
0
        public void Refresh()
        {
            Task refreshTask = new Task(() =>
            {
                DiscoveryServerDescriptor[] servers = null;
                using (DiscoveryClient client = new DiscoveryClient())
                {
                    servers = client.Discover(TimeSpan.Zero);
                }
                this.Dispatcher.InvokeAction(() =>
                {
                    int threads = servers.Select(s => s.ThreadCount).Sum();

                    this.textStatus.Text = servers.Length + " servers, " + threads + "+" + this.SettingsManager.Settings.ActualLocalConcurrencyLevel + " threads";

                    List<string> strings = new List<string>();
                    foreach (var server in servers)
                    {
                        strings.Add(server.Address + " (" + server.ThreadCount + " threads)");
                    }
                    strings.Sort();

                    this.listViewServers.Items.Clear();
                    foreach (var server in strings)
                    {
                        this.listViewServers.Items.Add(server);
                    }
                });
            });
            refreshTask.Start();
        }
コード例 #2
0
 private DiscoveryServerDescriptor[] GetServerList()
 {
     using (DiscoveryClient client = new DiscoveryClient())
     {
         return servers = client.Discover(TimeSpan.Zero);
     }
 }