We have multiple automation scripts (SRM Profile Load Scripts) that are trying to set the same parameters on the same element at the same time which causes troubles.
Currently we're using this as locking mechanism:
private static ConcurrentDictionary<string, object> lockDictionary = new ConcurrentDictionary<string, object>();
var lockObject = lockDictionary.GetOrAdd(mainElementId, (key) => new object());
lock (lockObject)
{
//do your sets
}
However this only works within the same SLAutomation process => if the scripts are running from the same DMA. In case of a cluster environment, how can I make sure that profile load scripts that are running on different DMAs are waiting for each other before making sets to the element?
Hi Jochen,
You could use an InterApp call instead of parameter sets. An InterApp message allows you to group the parameter values in one message so that the link between them doens't get lost. The connector can execute the desired action using the values from the message. Here is a link with more information on InterApp: https://docs.dataminer.services/develop/devguide/ClassLibrary/ClassLibraryInterAppClasses.html
Didn't test this yet, but another approach that might work is to let the script lock the elements it needs. Probably you'll need to call another subscript with the elements as input.
Hi Jochen,
I guess you can resolve this by using Mutex for your locking.
![](https://community.dataminer.services/wp-content/uploads/wp-user-manager-uploads/2022/03/97225679.jpg)
Hi Jens. A mutex can be used for inter-process communication on the same machine. This doesn’t work when the processes are running on different machines as in this case.
Hi Tom, I wasn’t aware of that. Is there something else that can be used instead?
![](https://community.dataminer.services/wp-content/uploads/wp-user-manager-uploads/2022/03/97225679.jpg)
Not out of the box. For locking that works over multiple machines, something that manages those locks will be needed (i.e. database, element, …). Clients connect to that manager to acquire and release the lock.
Do note that in case you make your API available as a NuGet your connector must use the exact same Class Library version as the one defined in the NuGet.