本文整理汇总了C#中Community.CsharpSqlite.Pager.xBusyHandler方法的典型用法代码示例。如果您正苦于以下问题:C# Pager.xBusyHandler方法的具体用法?C# Pager.xBusyHandler怎么用?C# Pager.xBusyHandler使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Community.CsharpSqlite.Pager
的用法示例。
在下文中一共展示了Pager.xBusyHandler方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: pager_wait_on_lock
/*
** Try to obtain a lock of type locktype on the database file. If
** a similar or greater lock is already held, this function is a no-op
** (returning SQLITE_OK immediately).
**
** Otherwise, attempt to obtain the lock using sqlite3OsLock(). Invoke
** the busy callback if the lock is currently not available. Repeat
** until the busy callback returns false or until the attempt to
** obtain the lock succeeds.
**
** Return SQLITE_OK on success and an error code if we cannot obtain
** the lock. If the lock is obtained successfully, set the Pager.state
** variable to locktype before returning.
*/
static int pager_wait_on_lock( Pager pPager, int locktype )
{
int rc; /* Return code */
/* The OS lock values must be the same as the Pager lock values */
Debug.Assert( PAGER_SHARED == SHARED_LOCK );
Debug.Assert( PAGER_RESERVED == RESERVED_LOCK );
Debug.Assert( PAGER_EXCLUSIVE == EXCLUSIVE_LOCK );
/* If the file is currently unlocked then the size must be unknown. It
** must not have been modified at this point.
*/
Debug.Assert( pPager.state >= PAGER_SHARED || pPager.dbSizeValid == false );
Debug.Assert( pPager.state >= PAGER_SHARED || pPager.dbModified == false );
/* Check that this is either a no-op (because the requested lock is
** already held, or one of the transistions that the busy-handler
** may be invoked during, according to the comment above
** sqlite3PagerSetBusyhandler().
*/
Debug.Assert( ( pPager.state >= locktype )
|| ( pPager.state == PAGER_UNLOCK && locktype == PAGER_SHARED )
|| ( pPager.state == PAGER_RESERVED && locktype == PAGER_EXCLUSIVE )
);
if ( pPager.state >= locktype )
{
rc = SQLITE_OK;
}
else
{
do
{
rc = sqlite3OsLock( pPager.fd, locktype );
} while ( rc == SQLITE_BUSY && pPager.xBusyHandler( pPager.pBusyHandlerArg ) != 0 );
if ( rc == SQLITE_OK )
{
pPager.state = (u8)locktype;
IOTRACE( "LOCK %p %d\n", pPager, locktype );
}
}
return rc;
}
示例2: pager_wait_on_lock
/*
** Try to obtain a lock of type locktype on the database file. If
** a similar or greater lock is already held, this function is a no-op
** (returning SQLITE_OK immediately).
**
** Otherwise, attempt to obtain the lock using sqlite3OsLock(). Invoke
** the busy callback if the lock is currently not available. Repeat
** until the busy callback returns false or until the attempt to
** obtain the lock succeeds.
**
** Return SQLITE_OK on success and an error code if we cannot obtain
** the lock. If the lock is obtained successfully, set the Pager.state
** variable to locktype before returning.
*/
static int pager_wait_on_lock( Pager pPager, int locktype )
{
int rc; /* Return code */
/* Check that this is either a no-op (because the requested lock is
** already held, or one of the transistions that the busy-handler
** may be invoked during, according to the comment above
** sqlite3PagerSetBusyhandler().
*/
Debug.Assert( ( pPager.eLock >= locktype )
|| ( pPager.eLock == NO_LOCK && locktype == SHARED_LOCK )
|| ( pPager.eLock == RESERVED_LOCK && locktype == EXCLUSIVE_LOCK )
);
do
{
rc = pagerLockDb( pPager, locktype );
} while ( rc == SQLITE_BUSY && pPager.xBusyHandler( pPager.pBusyHandlerArg ) != 0 );
return rc;
}