private async Task AddHostInfoNodes(TreeNode node, ResolveEventArgs args) { var hostNode = new TreeNode("Host: " + args.HostName) { Name = args.HostName }; node.Nodes.Add(hostNode); try { hostNode.Tag = await _service.LookupAsync(args.HostName, ProtocolFlags.IPv4v6, true, args.InterfaceIndex, hostNode); } catch (DnsServiceException dse) { WriteLine($"Lookup operation for host [{args.HostName}] failed: {dse.Message}"); } node.Nodes.Add(new TreeNode("Full Name: " + args.FullName)); node.Nodes.Add(new TreeNode("Port: " + args.Port)); if (args.TxtRecords != null) { var txtRecNode = new TreeNode("TXT Records"); node.Nodes.Add(txtRecNode); foreach (var txtRecord in args.TxtRecords) { var recNode = new TreeNode(txtRecord.ToString()); txtRecNode.Nodes.Add(recNode); } } }
private async void ServiceResolveEventHandler(object sender, ResolveEventArgs e) { if (sender is IOperationToken token && token.Context is TreeNode node) { treeViewServices.SuspendLayout(); WriteLine($"Adding node for host [{e.HostName}], Full Service Name [{e.FullName}]"); await AddHostInfoNodes(node, e); // Todo: we could cancel this operation here } if (!e.MoreComing) { treeViewServices.ResumeLayout(); } }