>>>>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?
>
>VFP9 by default does some extra table integrity checking when you open a table. This extra checking requires a temporary lock placed on the table header. Since someone else has the entire table FLOCK()ed, you can't get a lock on the header.
>
>The solution is SET TABLEVALIDATE TO 0.
Thanks to all for all the help.
Based on my testing, I think I want to use SET REPROCESS TO 1.
In this case, if the other program said USE foo EXCL, I will get a 1705 error. If the other program said USE foo shar, flock(), I will get a 108 error.
If, however, I use the SET TABLEVALIDATE TO 0, then if the other program said USE foo EXCL, I will get a 1705 error, but if the other program said USE foo SHAR, flock(), then VFP
allows me to proceed without error!. This not what I want!
Thanks again for the help