private void ReleaseConnection() { if (connection != null) { try { if (openCursorId != 0) { using (var message = new MongoKillCursorsMessage(cursor.Server, openCursorId)) { connection.SendMessage(message, SafeMode.False); // no need to use SafeMode for KillCursors } } cursor.Server.ReleaseConnection(connection); } finally { connection = null; openCursorId = 0; } } }
private void KillCursor() { if (openCursorId != 0) { try { if (serverInstance != null && serverInstance.State == MongoServerState.Connected) { var connection = serverInstance.AcquireConnection(cursor.Database); try { using (var message = new MongoKillCursorsMessage(connection, openCursorId)) { connection.SendMessage(message, SafeMode.False); // no need to use SafeMode for KillCursors } } finally { cursor.Server.ReleaseConnection(connection); } } } finally { openCursorId = 0; } } }