Product Documentation

c-treeDB API for C# - Developers Guide

Previous Topic

Next Topic

Starting Locks

Start acquiring locks by passing the appropriate lock mode to the Lock method inherited by CTSession, CTDatabase, CTTable, and CTRecord from CTBase.

// start locking

ARecord.Lock(LOCK_MODE.WRITE_BLOCK_LOCK);

After a successful call to Lock, the c-treeDB .NET API locks all records as they are read using the lock mode passed to Lock. Suspend record locking temporarily by calling the Lock function with the mode LOCK_MODE.SUSPEND_LOCK. Suspending locks does not release any locks, but while locks are suspended, no record reads are automatically locked.

// suspend locking

ARecord.Lock(LOCK_MODE.SUSPEND_LOCK);

Suspended locking can be resumed by calling Lock with a restore lock mode: LOCK_MODE.RESTORE_READ_LOCK, LOCK_MODE.RESTORE_READ_BLOCK_LOCK, LOCK_MODE.RESTORE_WRITE_LOCK, or LOCK_MODE.RESTORE_WRITE_BLOCK_LOCK.


// resume locking

try

{

ARecord.Lock(LOCK_MODE.RESTORE_WRITE_BLOCK_LOCK);

}

catch (CTException err)

{

Console.Write("Resume lock failed with error {0}\n", err.GetErrorCode());

}


TOCIndex