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 Cleanup() { OpenVPNClient client = null; lock (clientSync) { if (openVPNClient == null) { string errMsg = "OpenVPNTunnel::Cleanup(): OpenVPN client is not initialized"; EddieLogger.Error(errMsg); throw new Exception(errMsg); } client = openVPNClient; openVPNClient = null; } try { NativeMethods.EddieLibraryResult result = client.Stop(); if (result.code != NativeMethods.ResultCode.SUCCESS) { string errMsg = string.Format("OpenVPNTunnel::Cleanup(): Failed to stop OpenVPN client. {0}", result.description); EddieLogger.Error(errMsg); throw new Exception(errMsg); } } finally { ClearContexts(); } }