Share via


VariableDispenser.LockOneForWrite Method

Puts the variable in a list, and then locks it for read/write access.

Namespace:  Microsoft.SqlServer.Dts.Runtime
Assembly:  Microsoft.SqlServer.ManagedDTS (in Microsoft.SqlServer.ManagedDTS.dll)

Syntax

'Declaration
Public Sub LockOneForWrite ( _
    variable As String, _
    ByRef variables As Variables _
)
'Usage
Dim instance As VariableDispenser
Dim variable As String
Dim variables As Variables

instance.LockOneForWrite(variable, variables)
public void LockOneForWrite(
    string variable,
    ref Variables variables
)
public:
void LockOneForWrite(
    String^ variable, 
    Variables^% variables
)
member LockOneForWrite : 
        variable:string * 
        variables:Variables byref -> unit 
public function LockOneForWrite(
    variable : String, 
    variables : Variables
)

Parameters

  • variable
    Type: System.String
    The name of the variable to lock for read/write access.

Remarks

This method combines the work of the LockForWrite method and the GetVariables method in one call, as it applies to a single variable only.

If the call succeeds, the requested variable is returned as a one-entry collection in the variable collection specified by the parameter variables, and the variable is locked for read/write access. To unlock the variable, release the variable collection using the Unlock method of the Variables class. If the LockOneForWrite method call fails, the variable is not locked.

Calls to this method do not affect the lock list generated by calls to LockForWrite.

Note

It is recommended that you do not make multiple calls to this method when acquiring locks for variables to be used together because this could lead to deadlocks. All variables being used together should be requested and locked together by calling the methods LockForRead or LockForWrite, followed by a call to the GetVariables method.

If a lock was successful, you can clear it by calling Unlock.