First time poster - apologies if I am missing key information.
I am working on a project composed of two applications which rely on a USB license supporting concurrent licensing (e.g. only 10 users can access component x at the same time, between the 2 applications).
The USB license supports a mutex for accessing read/write functionality, but I am struggling on coming up with a model that would allow the two applications to communicate with one another to determine how many users are logged in total between the two applications.
In other words, if the USB dictates 10 users max, and application #1 has 2 users logged and application #2 has 8 users logged in, how can both applications know that an 11th user should not be allowed to be logged in?
The best I have come up with is to use a Mutex for an integer representing current users on a computer. When a user attempts to log into either application, that integer is checked. If user is allowed to login (because current # of users logged in < # of users licensed), then either application will allow this by modifying the mutex by incrementing it by 1.
And, when a user logs off the application, the application will decrement the mutex by 1 (releasing a "seat").
But, my concern then is if an application encounters an exception or a user force-quits an application that prevents it from calling the decrement, how should a "ghost occupied seat" be handled? (e.g. 5 out of 10 users were logged in, application crashed, mutex still says that 5 users are logged in when there's actually none).