// this function looks up the remote connections and for each one open // queries it for the API, target (usually executable name) and if any user is already connected private static void LookupHostConnections(object o) { { lookupMutex.WaitOne(); lookupsInProgress++; lookupMutex.ReleaseMutex(); } TreelistView.Node node = o as TreelistView.Node; Control p = node.OwnerView; while (p.Parent != null) { p = p.Parent; } RemoteHostSelect rhs = p as RemoteHostSelect; string hostname = node["Hostname"] as string; string username = System.Security.Principal.WindowsIdentity.GetCurrent().Name; StaticExports.EnumerateRemoteConnections(hostname, (UInt32 i) => { try { var conn = StaticExports.CreateRemoteAccessConnection(hostname, i, username, false); if (node.OwnerView.Visible) { string target = conn.Target; string api = conn.API; string busy = conn.BusyClient; node.OwnerView.BeginInvoke((MethodInvoker) delegate { node.OwnerView.BeginUpdate(); node.Nodes.Add(new TreelistView.Node(new object[] { target, api, busy })).Tag = new RemoteConnect(hostname, i); node.OwnerView.EndUpdate(); node.Expand(); }); } conn.Shutdown(); } catch (ApplicationException) { } }); if (node.OwnerView.Visible) { node.OwnerView.BeginInvoke((MethodInvoker) delegate { node.OwnerView.BeginUpdate(); node.Italic = false; node.Image = null; node.OwnerView.EndUpdate(); }); } { lookupMutex.WaitOne(); lookupsInProgress--; lookupMutex.ReleaseMutex(); } if (!rhs.IsDisposed && rhs.Visible) { rhs.BeginInvoke((MethodInvoker) delegate { rhs.LookupComplete(); }); } }
// this function looks up the remote connections and for each one open // queries it for the API, target (usually executable name) and if any user is already connected private static void LookupHostConnections(object o) { { lookupMutex.WaitOne(); lookupsInProgress++; lookupMutex.ReleaseMutex(); } TreelistView.Node node = o as TreelistView.Node; Control p = node.OwnerView; while (p.Parent != null) { p = p.Parent; } RemoteHostSelect rhs = p as RemoteHostSelect; string hostname = node["Hostname"] as string; var idents = StaticExports.EnumerateRemoteConnections(hostname); var remotes = new Dictionary <UInt32, AvailableRemote>(); string username = System.Security.Principal.WindowsIdentity.GetCurrent().Name; foreach (var i in idents) { if (i != 0) { try { var conn = StaticExports.CreateRemoteAccessConnection(hostname, i, username, false); var data = new AvailableRemote(conn.Target, conn.API, conn.BusyClient); conn.Shutdown(); remotes.Add(i, data); } catch (ApplicationException) { } } } if (node.OwnerView.Visible) { node.OwnerView.BeginInvoke((MethodInvoker) delegate { node.OwnerView.BeginUpdate(); node.Italic = false; node.Image = null; foreach (var kv in remotes) { node.Nodes.Add(new TreelistView.Node(new object[] { kv.Value.Target, kv.Value.API, kv.Value.Busy })).Tag = new RemoteConnect(hostname, kv.Key); node.Bold = true; } node.OwnerView.EndUpdate(); }); } { lookupMutex.WaitOne(); lookupsInProgress--; lookupMutex.ReleaseMutex(); } if (!rhs.IsDisposed && rhs.Visible) { rhs.BeginInvoke((MethodInvoker) delegate { rhs.LookupComplete(); }); } }