private void OnFindServersOnNetworkComplete(IAsyncResult result) { if (InvokeRequired) { BeginInvoke(new AsyncCallback(OnFindServersOnNetworkComplete), result); return; } try { ExpandNodeData data = (ExpandNodeData)result.AsyncState; DateTime lastCounterResetTime; List <ServerOnNetwork> servers = data.Lds.EndFindServersOnNetwork(result, out lastCounterResetTime); foreach (ServerOnNetwork server in servers) { if (server.ServerCapabilities.Contains("LDS")) { continue; } TreeNode node = new TreeNode(String.Format("{0}", server.ServerName)); node.SelectedImageIndex = node.ImageIndex = ImageIndex.Server; node.Tag = server; node.Nodes.Add(new TreeNode()); data.Parent.Nodes.Add(node); } if (DiscoveryTreeView.SelectedNode == data.Parent) { ShowServerOnNetworks(data.Parent.Nodes); } else { data.Parent.Expand(); } } catch (Exception e) { Opc.Ua.Client.Controls.ExceptionDlg.Show(Text, e); } }
private void OnFindServersComplete(IAsyncResult result) { if (InvokeRequired) { BeginInvoke(new AsyncCallback(OnFindServersComplete), result); return; } try { ExpandNodeData data = (ExpandNodeData)result.AsyncState; List <ApplicationDescription> servers = data.Lds.EndFindServers(result); foreach (ApplicationDescription server in servers) { if (server.ApplicationType == ApplicationType.DiscoveryServer) { continue; } TreeNode node = new TreeNode(String.Format("{0}", server.ApplicationName)); node.SelectedImageIndex = node.ImageIndex = (server.ApplicationType == ApplicationType.DiscoveryServer) ? ImageIndex.LocalNetwork : ImageIndex.Server; node.Tag = server; node.Nodes.Add(new TreeNode()); data.Parent.Nodes.Add(node); } if (DiscoveryTreeView.SelectedNode == data.Parent) { ShowApplicationDescriptions(data.Parent.Nodes); } else { data.Parent.Expand(); } } catch (Exception e) { Opc.Ua.Client.Controls.ExceptionDlg.Show(Text, e); } }