public void Cleanup() { OpenVPNClient client = null; lock (m_clientSync) { if (m_client == null) { throw new Exception("client not initialized"); } client = m_client; m_client = null; } try { if (!client.Stop()) { throw new Exception("client stop failed"); } } finally { ClearContexts(); } }
public void Init() { lock (m_clientSync) { if (m_client != null) { throw new Exception("client already initialized"); } m_client = OpenVPNClient.Create(ref m_clientInterface); if (m_client == null) { throw new Exception("client creation failed"); } } }
private void DoRun() { OpenVPNClient client = null; lock (m_clientSync) { if (m_client == null) { throw new Exception("client not initialized"); } client = m_client; // Do NOT call m_client.Start under m_clientSync'lock } // Dispatcher must be instantiated before starting to allow handling stop requests from outside while the client isn't started yet RunDispatcher(); if (!client.Start()) { throw new Exception("client start failed"); } }