Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
TRY...Catch problem
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Versions des environnements
Visual FoxPro:
VFP 9 SP2
OS:
Windows 7
Network:
Windows 2008 Server
Database:
Visual FoxPro
Application:
Desktop
Divers
Thread ID:
01608628
Message ID:
01608635
Vues:
41
Actually, I'm seeing that I can open the table even if it flocked(), but it will not open when the other user opens it exclusively.

However, when the other user opens it and flocks() it I cannot edit it and the error message will be "Record is in use by another user". And again you will want to use Set Reprocess when attempting to edit, save, update, replace.

>Yossi,
>
>Read the Help on Set Reprocess. I know it is hard to read and understand. In fact, when I worked at Microsoft I begged that it be rewritten. That and Tableupdate(). Both are equally confusing.
>
>The DEFAULT for SET Reprocess is 0, which means it will wait forever and that's not what you want.
>
>Also, keep in mind that if you are using a form with a private datasession you will need to again Set Reprocess to 5 since the command is scoped to a datasession.
>
>When you try to open a table SHARED it does not lock it for this discussion.
>
>So, try this on the non-locking client.
>
>
>set reprocess to 5  &&5 attempts
>
>try
>   use foo
>catch to ex
>   messagebox(ex.message)
>endtry
>
>
>
>>>>Hi All:
>>>>
>>>>I am running 2 instances of VFP to simulate a file sharing problem. When instance 1 says:
>>>>
>>>>
>>>>USE foo EXCL
>>>>
>>>>
>>>>This works in instance 2:
>>>>
>>>>
>>>>	TRY
>>>>		USE foo SHARED
>>>>	CATCH TO ww
>>>>		MESSAGEBOX('Problem!  You got error # ' + ALLTRIM(STR(ww.errorno)))
>>>>	ENDTRY
>>>>
>>>>
>>>>HOWEVER when instance 1 says:
>>>>
>>>>
>>>>USE foo
>>>>flock()
>>>>
>>>>
>>>>the 2nd instance just hangs with the following message in the status bar:
>>>>
>>>>
>>>>Attempting to lock... Press <esc> to cancel
>>>>
>>>>
>>>>How can I handle that situation gracefully with TRY..CATCH? I need this since the other system seems to be doing something like flock() and there's no way I can get the user to change the program.
>>>>
>>>>Thanks,
>>>>
>>>>Yossi
>>>
>>>You can use SET REPROCESS TO ... SECONDS to define how long you want to try to lock. And then check what value returned from flock() to see if it was successful or not. But the error won't be triggered.
>>>HTH.
>>
>>I'm not doing the flock(). It's the other guy. I'm just trying to USE the table SHARED. When the other guy has issued an flock(), I'm hanging with that Trying to lock... message.
>>
>>What kind of lock am I trying to do when I USE SHARED?
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform