Close Method

Collapse All Expand All Code: All Code: Multiple Code: C# Code: Visual Basic Code: Visual C++

C#
Visual Basic
Visual C++

Berkeley DB .NET API Documentation
DatabaseEnvironment..::.Close Method
DatabaseEnvironment Class See Also Send Feedback

By closing the Berkeley DB environment you can free allocated resources and close any open databases along with the underlying subsystems.

Namespace: BerkeleyDB
Assembly: libdb_dotnet53 (in libdb_dotnet53.dll) Version: 5.3.28.0

# Syntax

C#
    public void Close()

Visual Basic (Declaration)
    Public Sub Close

Visual C++
    public:
    void Close()

# Remarks

The object should not be closed while any other handle that refers to it is not yet closed; for example, database environment handles must not be closed while transactions in the environment have not yet been committed or aborted. When you close each database handle, by default, the database is not synchronized. To synchronize all open databases ensure that the last environment object is closed by the CloseForceSync() method. When the close operation fails, the method returns a non-zero error value for the first instance of such error, and continues to close the rest of the environment objects.

Where the environment was configured with UseTxns, calling CloseForceSync aborts any unresolved transactions. Applications should not depend on this behavior for transactions involving Berkeley DB databases; all such transactions should be explicitly resolved. The problem with depending on this semantic is that aborting an unresolved transaction involving database operations requires a database handle. Because the database handles should have been closed before calling CloseForceSync, it will not be possible to abort the transaction, and recovery will have to be run on the Berkeley DB environment before further operations are done.

In multithreaded applications, only a single thread may call CloseForceSync.

# See Also

DatabaseEnvironment Class
BerkeleyDB Namespace