Lock Property (Lck) - Call Operation (Magic xpa 2.x)
When a task or a program is called, Magic xpa suspends processing the current view record until the call returns. The called task or program has access to all the current view record's variables; in the case of programs, this access is to variables passed as arguments, while tasks have direct access. In either case, the called task or program may also update some of the current view record's variables. When using the On Modify locking strategy (the Locking Strategy is specified in the Task Properties dialog), the view record is locked immediately on the first change, or after a complete variable was accepted. If a called subtask or a program is about to change the current record, the developer should ensure that the current record is locked. Because subtasks and programs are complete execution units that can take some time to execute, it should be made impossible for other users to gain access to the current view record and modify it while the subtask or program is executing. Otherwise, a situation could arise where the current record could not be written to disk when the called subtask or program terminates. Therefore, the current record should be locked before executing the subtask or program. However, if the called subtask or program is not about to modify the current view record, the current view record should not be locked before executing the subtask or program, so as not to block other users' access to resources.
The purpose of the Lck property is to control locking when calling task or programs with arguments. Allowed values are:
No – Magic xpa will not lock the current view record when executing the task or program. It is the programmer's responsibility to verify that no updates will occur from the called process to the calling record variables. If such updates do occur they may be lost if the current view record cannot be written to disk due to changes made by other users.
Yes – The current view record will be locked immediately on executing the called task or program. Specify Yes for this property when the called task or program is going to update the current view record, or the updates performed by the called task or program must be done together with the current view record. Be aware that if the transaction is not yet opened, this mode is invalid. For instance, having a Call Task in the Record Prefix logic unit and opening the transaction before the Record Suffix logic unit.
Expression – An expression can be used to specify the value of the Lck property. Zoom to the Expression Editor.
This property is disabled in the Main Program.
There are a few exceptions that will not lock the current data view record even though the developer specifies Yes as the Lock property:
-
The locking strategy of the task is defined as 'Before Update' or 'No Lock'. In this case, the task locking behavior overrides the Lock property of the Call operation.
-
No arguments are passed to the called program, or all the arguments are passed as expressions (by value).