Multi-User Process Notification Method

I have an app in a multi-user windows environment connected to an MS SQL database. All of these users are on the same internal network. I have a process that collects data and rebuilds a table in my database, then presents the data for the user(s) to review. The rebuild process takes a few minutes.

Once the process starts, I need to prevent other users from starting the process until the existing process completes, however they can use the many other features of the app, which is necessary.

I thought I’d just create a new table in the database that updates the process status and when a user tries to execute the process it checks to see if an existing process is in progress, then declines a new execution until completed. Seems simple in theory, but if the user who started the process computer is shut down prior to completion or becomes disconnected from network this breaks and leaves a zombie status in the DB.

What other approaches or ideas does my group of esteemed colleagues have for something like this?

Run a server side component for the app: The user initiates the process, possibly by writing data to a database table, the server component detects this and runs the required process. The server part is less likely to disconnect, and you can put recovery code there as well.

1 Like

Timestamp the status and decide on a reasonable “timeout”.

1 Like

Both great ideas, thanks guys…

Less likely but is the exact same problem he want to prevent.

This is better, but improbving on that, you can also add a progress to the process with the Timestamp

1 Like

One solution that I’ve used in the past for this sort of thing is UDP broadcasts. That way you actually get an event within a moment of the action.

1 Like

You need to create some kind of mutex.

I found this after a quick Google:

1 Like

Since you mention that all users are on the same internal network, you may be able to use a shared file. When starting the process, open the file for exclusive access - typically write access will do this. No need to actually write to the file. Close the file when done. If the process gets an error opening the file it means another process is using it. The file system (operating system) will close the file if the process terminates. (Make sure all users have write access to the file/folder.)

1 Like