MoneyWorks Manual
Edit
!--sphider_noindex-->
GetMutex (name)
Definition: Attempts to obtain a named mutex from the server. If another user already has the named mutex, returns 0, else 1 if successful. Always successful on a single user system.
Use this when you need to ensure that some operation will only be executed by one client.
Example usage:
    // only do once per week    
    if GetMutex("rate_update")    // make sure only one client at a time runs this code
        let values = GetPersistent("user2", kMyDevKey, "last_currency_update")
        if values["date1"] < Today() - 7 and DateToPeriod(Today()) = CurrentPeriod()
            
            GetRates()
            
            let values["date1"] = Today()
            SetPersistent("user2", kMyDevKey, "last_currency_update", values)
        endif
        ReleaseMutex("rate_update")
    endif
Availability: MWScript handlers
See Also:
ReleaseMutex: Release a mutex