Managed Dbf

Click here to edit subtitle


Record locking

Posted by nhylzcode on April 24, 2015 at 2:15 PM

Visual Foxpro and Xbase has a RLOCK() and FLOCK() for it's record and file locking mechanism but only returns logical value .T. or .F., true if you successfully lock the file or a certain record, otherwise it returns false if failed. But there are times I need to know whether the record is lock by the application or it is locked by another process. What i've implemented in Managed Dbf; rather than just returning locical value true or false it returned an integet value ranging for 0 to 3.

0 - If current record is not lock.
1 - If locked by the application.
2 - if locked by other process local or other user from lan.
3 - If locking on invalid record ranged.

CUSTOMER.Navigator.GoTo( 100 );
If (  !  CUSTOMER.Locker.Lock() )

mRet = CUSTOMER.Locker.IsLocked();
     if ( mRet == 0 ) MessageBox.Show(" Record is free ");

     if ( mRet == 1 ) MessageBox.Show(" This record is lock by this process ");

     if ( mRet == 2 ) MessageBox.Show(" Ooopss other user or process lock this record ");

     if ( mRet == 3 ) MessageBox.Show(" Invalid record position ");

     MessageBox.Show(" Record locking successfull ^_^y ");

But of course,  theres an overload to lock specific record number :)

// Lock record no 100
CUSTOMER.Locker.Lock( 100 );

Categories: None

Post a Comment


Oops, you forgot something.


The words you entered did not match the given text. Please try again.

Already a member? Sign In