public void Shutdown() { // Shutdown sequence //Console.WriteLine("Shutdown in progress..."); if (m_Sink != null) { m_Sink.Unregister(m_SrvEx); m_Sink = null; } }
public void Initialize() { if (m_SrvEx != null) { return; //Already initialized } Thread.CurrentThread.SetApartmentState(ApartmentState.STA); try { AgentServer AgSrv = new AgentServer(); // The following cast does the QueryInterface to fetch IAgentEx interface from the IAgent interface, directly supported by the object m_SrvEx = (IAgentEx)AgSrv; m_Sink = new AgentNotifySink(); m_Sink.Register(m_SrvEx); } catch (Exception e) { AgentServerStartupException ex = new AgentServerStartupException("Agent Server could not be started", e); Console.WriteLine(ex); throw ex; } }