Variables.Locked Property
A Boolean indicating whether the variables in the Variables collection are locked.
Namespace: Microsoft.SqlServer.Dts.Runtime
Assembly: Microsoft.SqlServer.ManagedDTS (in microsoft.sqlserver.manageddts.dll)
Assembly: Microsoft.SqlServer.ManagedDTS (in microsoft.sqlserver.manageddts.dll)
The Variables collection contains a Locked property that indicates whether a variable dispenser collection of variables is locked (true) or unlocked (false). The reason to review this property is that some tasks explicitly release locks to the variables they are using, and calling Unlock twice throws an error. Therefore, you should use Locked property determine whether the dispensed collection is locked before calling Unlock.
The following code example locks the variable collection when GetVariables is called. The example then determines whether the collection is locked and, if the collection is locked, calls Unlock.
using System; using System.Collections.Generic; using System.Text; using Microsoft.SqlServer.Dts.Runtime; namespace Microsoft.SqlServer.SSIS.Sample { class Program { static void Main(string[] args) { Package pkg = new Package(); Variables vars = null; VariableDispenser variableDispenser = pkg.VariableDispenser; variableDispenser.LockForRead("System::PackageName"); variableDispenser.LockForRead("System::OfflineMode"); variableDispenser.LockForWrite("System::InteractiveMode"); variableDispenser.GetVariables(ref vars); // Determine whether the variable collection is locked before unlocking. Boolean isLocked = vars.Locked; // Verify the value of vars.Locked. If the lock failed, // call Reset. if (isLocked) { vars.Unlock(); } else { variableDispenser.Reset(); } } } }
Development Platforms
For a list of the supported platforms, see Hardware and Software Requirements for Installing SQL Server 2005.Target Platforms
For a list of the supported platforms, see Hardware and Software Requirements for Installing SQL Server 2005.