DIAdem API Reference

Command: ExecuteExclusiveBegin

  • Updated2023-02-21
  • 3 minute(s) read

Display all  Hide all

Starts the execution of a script section with mutual exclusion (mutex). Another program instance, which also starts the execution of a mutually exclusive script section for which it uses the same name, will wait for the first instance to finish the execution of the script section. You create a mutual exclusion by inserting the critical script lines into the ExecuteExclusiveBegin and ExecuteExclusiveEnd commands. Use these commands, for example, for parallel processes with multiple Worker objects or within SystemLink TDM to access files exclusively.

ReturnValue = ExecuteExclusiveBegin(ExecuteExclusiveName, [ExecuteExclusiveTimeout])

Input Parameters

ExecuteExclusiveName Specifies the name for executing a mutually exclusive script section.
[ExecuteExclusiveTimeout] Specifies the time in seconds that DIAdem waits for the execution of a mutually exclusive script section. If you specify a negative value, DIAdem waits for another instance to release the execution of a mutually exclusive script section.

Return Parameters

ReturnValue Specifies the handle that DIAdem returns when executing a mutually exclusive script section. If the handle is smaller than 0, another instance executes a mutually exclusive script section and has not yet released execution.

Examples

The following example starts executing a mutually exclusive script section to open a file and write to that file. If it is not possible to execute a mutually exclusive script section after ten seconds, this DIAdem instance aborts execution with a debug message.

VBScriptPython

 

Dim intExecuteExclusiveHandle, intMyFileHandle, intMyError
intExecuteExclusiveHandle = ExecuteExclusiveBegin("WriteFile",10) 
If intExecuteExclusiveHandle < 0 Then 
  Call DBM ("Timeout: Could not write file")
Else
  intMyFileHandle =  TextFileOpen(CurrentScriptPath & "MyFile.txt", eTextFileAttributeExclusive OR eTextFileAttributeWrite OR eTextFileAttributeANSI)
  Call TextFileWriteln(intMyFileHandle,"Test")
  intMyError = TextFileClose(intMyFileHandle)
End If
Call ExecuteExclusiveEnd(intExecuteExclusiveHandle)

Related Topics

Command: ExecuteExclusiveEnd | Command: ExecuteExclusiveEndAll