I am trying to use a Mutex to prevent multiple copies of my
application from writing to the same REALSQLdatabase file.
My code below seems to be working as expected -- logging confirms
that exactly one copy is being written to the database and by one
application instance (confirmed by PID). However, I am *not* using
the Mutex.Leave() command, and that worries me a great deal that at
some point this application would "blowup" because of Recursive calls
to the Mutex.
My question is if this is the proper way to lock the REALSQLdatabase
resource?
There are no examples of the new REALbasic Mutex Class that I am
aware of.
------------
Private Sub DbWriteMutex(sql As String)
Static mtx As New Mutex("MyApp2006")
If mtx.TryEnter Then
Db.SQLExecute(sql)
If Db.Error Then
System.DebugLog "[" + Str(Db.ErrorCode) + "] " + Db.ErrorMessage
Else
Db.Commit
End If
System.DebugLog "WRITE for PID#: " + Format
(ProcessLib.GetCurrentProcess, "0")
System.DebugLog sql
Else
System.DebugLog "ERROR: Another copy is already running (this
PID#: " _
+ Format(ProcessLib.GetCurrentProcess, "0") + ")"
System.DebugLog "FAILED: " + sql
End If
End Sub
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>
Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>