private static extern RCODE xflaim_Db_getLockType( IntPtr pDb, out eLockType peLockType, out int pbImplicit);
private static extern RCODE xflaim_Db_getLockInfo( IntPtr pDb, int iPriority, out eLockType eLckType, out uint uiThreadId, out uint uiNumExclQueued, out uint uiNumSharedQueued, out uint uiPriorityCount);
private static extern RCODE xflaim_Db_dbLock( IntPtr pDb, eLockType eLckType, int iPriority, uint uiTimeout);
//----------------------------------------------------------------------------- // getLockType //----------------------------------------------------------------------------- /// <summary> /// Get the type of database lock current held. /// </summary> /// <param name="eLckTyp"> /// Type of lock is returned here. /// </param> /// <param name="bImplicit"> /// Flag indicating whether the database was implicitly locked is /// returned here. Returns true if implicitly locked, false if /// explicitly locked. Implicit lock means that the database was /// locked at the time the transaction was started. Explicit lock /// means that the application called <see cref="dbLock"/> to /// obtain the lock. /// </param> public void getLockType( out eLockType eLckTyp, out bool bImplicit) { RCODE rc; int bImpl; if ((rc = xflaim_Db_getLockType( m_pDb, out eLckTyp, out bImpl)) != 0) { throw new XFlaimException( rc); } bImplicit = bImpl != 0 ? true : false; }
//----------------------------------------------------------------------------- // getLockInfo //----------------------------------------------------------------------------- /// <summary> /// Return various pieces of lock information. /// </summary> /// <param name="iPriority"> /// Priority to look for. The uiPriorityCount parameter returns a count /// of all waiting threads with a lock priority greater than or equal to /// this. /// </param> /// <param name="eLckType"> /// Returns the type of database lock current held. /// </param> /// <param name="uiThreadId"> /// Returns the thread id of the thread that currently holds the database lock. /// </param> /// <param name="uiNumExclQueued"> /// Returns the number of threads that are currently waiting to obtain /// an exclusive database lock. /// </param> /// <param name="uiNumSharedQueued"> /// Returns the number of threads that are currently waiting to obtain /// a shared database lock. /// </param> /// <param name="uiPriorityCount"> /// Returns the number of threads that are currently waiting to obtain /// a database lock whose priority is >= iPriority. /// </param> public void getLockInfo( int iPriority, out eLockType eLckType, out uint uiThreadId, out uint uiNumExclQueued, out uint uiNumSharedQueued, out uint uiPriorityCount) { RCODE rc; if ((rc = xflaim_Db_getLockInfo( m_pDb, iPriority, out eLckType, out uiThreadId, out uiNumExclQueued, out uiNumSharedQueued, out uiPriorityCount)) != 0) { throw new XFlaimException( rc); } }
//----------------------------------------------------------------------------- // dbLock //----------------------------------------------------------------------------- /// <summary> /// Lock the database. /// </summary> /// <param name="eLckType"> /// Type of lock being requested. /// </param> /// <param name="iPriority"> /// Priority of lock being requested. /// </param> /// <param name="uiTimeout"> /// Lock wait time. Specifies the amount of time to wait for /// database lock. Valid values are 0 through 255 seconds. /// Zero is used to specify no-wait locks. 255 is used to specify /// that there is no timeout. /// </param> /// <returns></returns> public void dbLock( eLockType eLckType, int iPriority, uint uiTimeout) { RCODE rc; if ((rc = xflaim_Db_dbLock( m_pDb, eLckType, iPriority, uiTimeout)) != 0) { throw new XFlaimException(rc); } }