VariableDispenser.Reset Method
Clears both the read-only list and read/write list when the call to GetVariables fails.
Namespace: Microsoft.SqlServer.Dts.Runtime
Assembly: Microsoft.SqlServer.ManagedDTS (in microsoft.sqlserver.manageddts.dll)
Syntax
'Declaration
Public Sub Reset
public void Reset ()
public:
void Reset ()
public void Reset ()
public function Reset ()
Remarks
Updated sample code:17 July 2006
This method can be used to clear the read-only list and the read/write lock list after a call to GetVariables has failed. If a call to GetVariables fails, the lock lists are not cleared and therefore, if you call GetVariables again, an attempt will be made to lock the same variables. If you want to retry locking the same variables, call GetVariables again without calling Reset first. Or, you can choose to release the lists by using this method and abandoning the operation until all required variables are available and can be locked at once.
Additionally, the Reset method is used if you receive a failure from GetVariables and you want to lock a completely different and unrelated set of variables next. You would call Reset to clear the lock lists, and then refill the lock lists by using the LockForRead, LockForWrite, LockOneForRead, and LockOneForWrite methods.
Example
The following code example locks a collection of variables, and then determines whether the variable collection is locked before unlocking them. If the lock failed, then Reset is called.
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.GetVariables(ref vars);
// Determine whether the variable collection is locked.
Boolean isLocked = vars.Locked;
// Verify the value of vars.Locked. If the lock failed,
// call Reset.
if (isLocked)
{
vars.Unlock();
}
else
{
variableDispenser.Reset();
}
}
}
}
Imports System
Imports System.Collections.Generic
Imports System.Text
Imports Microsoft.SqlServer.Dts.Runtime
Namespace Microsoft.SqlServer.SSIS.Sample
Class Program
Shared Sub Main(ByVal args() As String)
Dim pkg As Package = New Package()
Dim vars As Variables = Nothing
Dim variableDispenser As VariableDispenser = pkg.VariableDispenser
variableDispenser.LockForRead("System::PackageName")
variableDispenser.LockForRead("System::OfflineMode")
variableDispenser.GetVariables( vars)
' Determine whether the variable collection is locked.
Dim isLocked As Boolean = vars.Locked
' Verify the value of vars.Locked. If the lock failed,
' call Reset.
If isLocked = True Then
vars.Unlock()
Else
variableDispenser.Reset()
End If
End Sub
End Class
End Namespace
Thread Safety
Any public static (Shared in Microsoft Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Platforms
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.
See Also
Reference
VariableDispenser Class
VariableDispenser Members
Microsoft.SqlServer.Dts.Runtime Namespace
Change History
Release |
History |
17 July 2006 |
Changed content:
|