Greatly speed up 'attach to running instance' dialog in the 99% case

* 99% of the time, you'll only have localhost and the application will
  be running on the first ident checked which will return a valid socket
  almost immediately.
* Instead of continuing to search through each valid port before
  returning valid data, we change the enumerate function to just find
  the next valid port and return - so we can update the UI as soon as
  we have the first result.
This commit is contained in:
baldurk
2016-06-01 11:31:57 +02:00
parent 4b149abdbd
commit 094e79dee2
5 changed files with 63 additions and 77 deletions
+12 -16
View File
@@ -69,29 +69,25 @@ namespace renderdocui.Windows.Dialogs
var updateThread = Helpers.NewThread(new ThreadStart(() =>
{
var idents = renderdoc.StaticExports.EnumerateRemoteConnections("localhost");
string runningPrograms = "";
int running = 0;
foreach (var i in idents)
renderdoc.StaticExports.EnumerateRemoteConnections("localhost", (UInt32 i) =>
{
if (i != 0)
{
running++;
running++;
var conn = renderdoc.StaticExports.CreateRemoteAccessConnection("localhost", i, "updater", false);
var conn = renderdoc.StaticExports.CreateRemoteAccessConnection("localhost", i, "updater", false);
if (runningPrograms != "")
runningPrograms += "\n";
if (runningPrograms != "")
runningPrograms += "\n";
if (conn.API != "")
runningPrograms += String.Format("{0} running {1}", conn.Target, conn.API);
else
runningPrograms += conn.Target;
if (conn.API != "")
runningPrograms += String.Format("{0} running {1}", conn.Target, conn.API);
else
runningPrograms += conn.Target;
conn.Shutdown();
}
}
conn.Shutdown();
});
if (running > 0)
{