VariableDispenser.Reset Method

Clears both the read-only list and read/write list when the call to GetVariables fails.

命名空间: Microsoft.SqlServer.Dts.Runtime
程序集: Microsoft.SqlServer.ManagedDTS (in microsoft.sqlserver.manageddts.dll)

语法

声明
Public Sub Reset
public void Reset ()
public:
void Reset ()
public void Reset ()
public function Reset ()

备注

已更新的示例代码:2006 年 7 月 17 日

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.

示例

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

线程安全

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.

平台

开发平台

有关支持的平台列表,请参阅安装 SQL Server 2005 的硬件和软件要求。

目标平台

有关支持的平台列表,请参阅安装 SQL Server 2005 的硬件和软件要求。

请参阅

参考

VariableDispenser Class
VariableDispenser Members
Microsoft.SqlServer.Dts.Runtime Namespace