public void Start() { NTrace.Info("Starting"); this.channel = ServerUtilities.GetTcpChannel(); NTrace.Debug("Acquired Tcp Channel"); try { this.agency = (TestAgency)Activator.GetObject(typeof(TestAgency), agencyUrl); NTrace.DebugFormat("Connected to TestAgency at {0}", agencyUrl); } catch (Exception ex) { NTrace.ErrorFormat("Unable to connect to test agency at {0}", agencyUrl); NTrace.Error(ex.Message); } try { this.agency.Register(this, ProcessId); NTrace.Debug("Registered with TestAgency"); } catch (Exception ex) { NTrace.Error("Failed to register with TestAgency", ex); } }
private AgentRecord FindAvailableRemoteAgent(AgentType type) { foreach (AgentRecord r in agentData) { if (r.Status == AgentStatus.Ready) { NTrace.DebugFormat("Reusing agent {0}", r.Id); r.Status = AgentStatus.Busy; return(r); } } return(null); }
private AgentRecord CreateRemoteAgent(AgentType type, int waitTime) { int pid = LaunchAgentProcess(); NTrace.DebugFormat("Waiting for agent {0} to register", pid); while (waitTime > 0) { int pollTime = Math.Min(200, waitTime); Thread.Sleep(pollTime); waitTime -= pollTime; if (agentData[pid].Agent != null) { NTrace.DebugFormat("Returning new agent record {0}", pid); return(agentData[pid]); } } return(null); }