Level: Intermediate, Version: FM 12 or later

Process Lock that Clears Itself

If you build multi-user business systems, you may have had a need at one time or another to temporarily “lock” a process, so that only one user at a time can perform it. A typical drawback to most process locking approaches is that the lock does not automatically clear if the user who locked the process crashes or otherwise bails out of the system abnormally.

Well, I have some good news: Bob Gossom of Absolute Advantage has come up with a very clever, and well-documented, self-clearing process lock technique, which I’m pleased to share here with his permission.

6-24-2014 2-33-36 AM

Demo file: procedure-locking.zip

Notes from the demo: Occasionally we need to program a process that should only be done by one user. The most typical approach is to set a field at the start of the process, and then clear it when you are done. This generally works unless the user quits or crashes FMP, at which point the process will  be improperly locked.

This file shows a method that locks a procedure with record locking. If the user that locks the process quits or crashes, the process will automatically be re-opened for other users.

The “Lock” process will work single user. Simply click on one of the “Lock” buttons twice. The second time you be notified that the procedure is locked (by you).

To really test it, share the file (best on Server) and open it with two different Client sessions at the same time. Lock a process and then Quit/Exit. The process will become available to the other client.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.