Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Set Reprocess setting problem

Status
Not open for further replies.

mstrcmtr

Programmer
Nov 14, 2007
103
PK
SET MULTILOCKS ON && Required for row or table buffering and allows multiple records to be locked using LOCK( ) or RLOCK( )

SET REFRESH TO 5,3
SET REPROCESS TO 5 SECONDS

Above are the setting for locking table BUT want to stop until or unless counter table Locked

For Locking using the following code

LOCAL isLocked , nKey

SELECT Counter

WAIT WINDOW 'Trying to Lock [ Computer No ] Table .... ' NOWAIT

do while ! m.isLocked
m.isLocked = flock('Counter')
enddo

RETURN m.isLocked

But not pausing the process until or unless file locked
 
The parameters of REPROCESS are about automatic locks, not manual locks.

You're responsible how you want react to not getting manual locks yourself, that's not influenced by settings. There is no automatic EXIT of locking loops you do this way, how should there be, at what level should the exiting stop? There still is no general AI working in the background in a runtime.

Bye, Olaf.

 
What i understand

Set the Set Reprocess to Auto

2nd i have following code in OP Do while Loop

if m.nKey=27 && If Loop INTERRUPTED by Esc Key
exit
endif


 
No

The delay is not relavant to LOCKS/RLOCKSat all, it is relevant to times you want to either USE a file exclusive that's open by someone else or UPDATE a file that's locked in the cahnged rrows by soemeone else and the delay just delays the ERROR 3 or 108 you get after VFP reprocessed the locking it needs for the USE or the UPDATE or TABLEUPDATE or whatever is the cause of the automatic locks is.

LOCK/RLOCK immediately give you a .F. or .T. and that never changes when you SET REPROCESS.

I said REPROCESS can't interfere with your code, it can't exit from a loop you do. And if you instread put an EXIT in your code, you immediately exit the code.

If you want to reproces RLOCKS, then simply do so with YOUR code.

Bye, Olaf.
 
Using the following code for table locking Please guide the best code for locking table trying to lock until or unless table locked

LOCAL isLocked , nKey

SELECT Gjno

WAIT WINDOW 'Trying to Lock [ Computer No ] Table .... ' NOWAIT

thisform.pp_cntlck = 1

DO WHILE ! m.isLocked

m.isLocked = FLOCK('Gjno')

thisform.pp_cntlck = thisform.pp_cntlck + 1

nKey=inkey()

if m.nKey=27 && If Loop INTERRUPTED by Esc Key
exit
endif

IF m.isLocked = .F. && If Flock Un-Successful then loop
LOOP
ENDIF

ENDDO

RETURN m.isLocked
 
I tried. For FLOCK() SET REPROCESS works, Just don't do any loop.

Code:
Local llSuccess && intially .F.
SET REPROCESS TO 30 SECONDS
SELECT Table
llSuccess=FLOCK()

I wouldn't try to lock for 30 seconds, though. Normally either you get a lock or you don't. There is almost no situation you get the lock after say half the timeout. You either get it immediately or the timeout happens. Unless you stage a situation where you yourself block the lock with another VFP session you end. But real life situations are rarely that way. Instead try to get exclusive use:

Code:
Local llSuccess && intially .F.
USE IN SELECT("Table") && close table
TRY
   USE Table In 0 EXCLUSIVE
   llSuccess = .T.
CATCH
   * Didn't work
ENDTRY

The loop you did initially would never stop until you get the lock:
Code:
do while ! m.isLocked
m.isLocked = flock('Counter')
enddo

Each loop iteration takes the time you specified in REPROCESS with SECONDS clause. But it runs endless, you could also SET REPROCESS TO -1 and just do FLOCK once. I'd spare users the time to wait for a timeout, though. It's a useless concept. When you don't have immediate success typically something is wrong and needs to be addressed anyway, eg any other session of the application hangs. Programming with manual locks is really unfortunate. Is your counter table used to create IDs?

Bye, Olaf.


 
Counter table (GjNo) providing Entry No for New Entries which is Unique and user has to save entry in Journal table

Earlier you said that Set Reprocess setting is not for FLOCK , LOCK
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top