Track busy and active connections and display in UI

This commit is contained in:
baldurk
2016-08-04 14:32:45 +02:00
parent 8a5d300e78
commit 2060173049
5 changed files with 50 additions and 31 deletions
+6
View File
@@ -45,6 +45,12 @@ namespace renderdocui.Code
[XmlIgnore]
public bool ServerRunning = false;
[XmlIgnore]
public bool Connected = false;
[XmlIgnore]
public bool Busy = false;
public void Launch()
{
try
+17 -11
View File
@@ -63,7 +63,8 @@ namespace renderdocui.Code
private Thread m_Thread;
private string m_Logfile;
private bool m_Running;
private RemoteServer m_Remote;
private RemoteHost m_RemoteHost = null;
private RemoteServer m_Remote = null;
private List<InvokeHandle> m_renderQueue;
@@ -107,14 +108,6 @@ namespace renderdocui.Code
}
}
public bool IsRemoteConnected
{
get
{
return m_Remote != null;
}
}
public void DeleteCapture(string logfile, bool local)
{
if (Running)
@@ -142,13 +135,20 @@ namespace renderdocui.Code
set { m_Running = value; m_WakeupEvent.Set(); }
}
public void ConnectToRemoteServer(string hostname)
public RemoteHost Remote
{
get { return m_RemoteHost; }
}
public void ConnectToRemoteServer(RemoteHost host)
{
InitException = null;
try
{
m_Remote = StaticExports.CreateRemoteServer(hostname, 0);
m_Remote = StaticExports.CreateRemoteServer(host.Hostname, 0);
m_RemoteHost = host;
m_RemoteHost.Connected = true;
}
catch (ReplayCreateException ex)
{
@@ -158,8 +158,14 @@ namespace renderdocui.Code
public void DisconnectFromRemoteServer()
{
if (m_RemoteHost != null)
m_RemoteHost.Connected = false;
if (m_Remote != null)
m_Remote.ShutdownConnection();
m_RemoteHost = null;
m_Remote = null;
}
public ReplayCreateException InitException = null;
+1 -1
View File
@@ -270,7 +270,7 @@ namespace renderdocui.Windows.Dialogs
string exe = exePath.Text;
// for non-remote captures, check the executable locally
if (!m_Core.Renderer.IsRemoteConnected)
if (m_Core.Renderer.Remote == null)
{
if (!File.Exists(exe))
{
+22 -9
View File
@@ -62,11 +62,12 @@ namespace renderdocui.Windows.Dialogs
get { return "No remote server"; }
}
private static void SetRemoteServerLive(TreelistView.Node node, bool live)
private static void SetRemoteServerLive(TreelistView.Node node, bool live, bool busy)
{
RemoteHost host = node.Tag as RemoteHost;
host.ServerRunning = live;
host.Busy = busy;
if (host.Hostname == "localhost")
{
@@ -75,7 +76,14 @@ namespace renderdocui.Windows.Dialogs
}
else
{
node["running"] = live ? RemoteServerLiveText : RemoteServerDeadText;
string text = live ? RemoteServerLiveText : RemoteServerDeadText;
if (host.Connected)
text += " (Active Context)";
else if (host.Busy)
text += " (Busy)";
node["running"] = text;
node.Image = live
? global::renderdocui.Properties.Resources.connect
@@ -162,20 +170,22 @@ namespace renderdocui.Windows.Dialogs
string hostname = node["hostname"] as string;
RemoteHost host = node.Tag as RemoteHost;
string username = System.Security.Principal.WindowsIdentity.GetCurrent().Name;
try
{
RemoteServer server = StaticExports.CreateRemoteServer(hostname, 0);
SetRemoteServerLive(node, true);
SetRemoteServerLive(node, true, false);
server.ShutdownConnection();
}
catch (ReplayCreateException ex)
{
if(ex.Status == ReplayCreateStatus.NetworkRemoteBusy)
SetRemoteServerLive(node, true);
if (ex.Status == ReplayCreateStatus.NetworkRemoteBusy)
SetRemoteServerLive(node, true, true);
else
SetRemoteServerLive(node, false);
SetRemoteServerLive(node, false, false);
}
StaticExports.EnumerateRemoteTargets(hostname, (UInt32 i) => {
@@ -284,9 +294,12 @@ namespace renderdocui.Windows.Dialogs
if (host != null)
{
if(IsRemoteServerLive(hosts.SelectedNode))
if(host.ServerRunning)
{
connect.Text = "Shutdown";
if (host.Busy || host.Connected)
connect.Enabled = false;
}
else
{
@@ -360,7 +373,7 @@ namespace renderdocui.Windows.Dialogs
{
RemoteHost host = node.Tag as RemoteHost;
if (IsRemoteServerLive(node))
if (host.ServerRunning)
{
DialogResult res = MessageBox.Show(String.Format("Are you sure you wish to shut down running remote server on {0}?", host.Hostname),
"Remote server shutdown", MessageBoxButtons.YesNoCancel);
@@ -374,7 +387,7 @@ namespace renderdocui.Windows.Dialogs
RemoteServer server = StaticExports.CreateRemoteServer(host.Hostname, 0);
server.ShutdownServerAndConnection();
hosts.BeginUpdate();
SetRemoteServerLive(node, false);
SetRemoteServerLive(node, false, false);
hosts.EndUpdate();
}
catch (Exception)
+4 -10
View File
@@ -72,8 +72,6 @@ namespace renderdocui.Windows
private string m_InitRemoteHost;
private uint m_InitRemoteIdent;
private RemoteHost m_RemoteHost = null;
private List<LiveCapture> m_LiveCaptures = new List<LiveCapture>();
private string InformationalVersion
@@ -589,8 +587,8 @@ namespace renderdocui.Windows
prefix += " - ";
}
if (m_RemoteHost != null)
prefix += String.Format("Remote: {0} - ", m_RemoteHost.Hostname);
if (m_Core != null && m_Core.Renderer.Remote != null)
prefix += String.Format("Remote: {0} - ", m_Core.Renderer.Remote.Hostname);
Text = prefix + "RenderDoc ";
if(OfficialVersion)
@@ -795,7 +793,7 @@ namespace renderdocui.Windows
return null;
}
var live = new LiveCapture(m_Core, m_RemoteHost == null ? "" : m_RemoteHost.Hostname, ret, this);
var live = new LiveCapture(m_Core, m_Core.Renderer.Remote == null ? "" : m_Core.Renderer.Remote.Hostname, ret, this);
ShowLiveCapture(live);
return live;
}
@@ -923,8 +921,6 @@ namespace renderdocui.Windows
injectIntoProcessToolStripMenuItem.Enabled = true;
m_RemoteHost = null;
statusText.Text = "";
SetTitle();
@@ -942,8 +938,6 @@ namespace renderdocui.Windows
injectIntoProcessToolStripMenuItem.Enabled = false;
m_RemoteHost = host;
SetTitle();
statusText.Text = "Checking remote server status...";
@@ -986,7 +980,7 @@ namespace renderdocui.Windows
if (host.ServerRunning)
{
m_Core.Renderer.DisconnectFromRemoteServer();
m_Core.Renderer.ConnectToRemoteServer(host.Hostname);
m_Core.Renderer.ConnectToRemoteServer(host);
}
this.BeginInvoke(new Action(() =>