Condividi tramite


VariableDispenser.Reset Method

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

Spazio dei nomi: Microsoft.SqlServer.Dts.Runtime
Assembly : Microsoft.SqlServer.ManagedDTS (in microsoft.sqlserver.manageddts.dll)

Sintassi

'Dichiarazione
Public Sub Reset
public void Reset ()
public:
void Reset ()
public void Reset ()
public function Reset ()

Osservazioni

Codice di esempio aggiornato:17 luglio 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.

Esempio

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.

Piattaforme

Piattaforme di sviluppo

Per un elenco delle piattaforme supportate, vedere Requisiti hardware e software per l'Installazione di SQL Server 2005.

Piattaforme di destinazione

Per un elenco delle piattaforme supportate, vedere Requisiti hardware e software per l'Installazione di SQL Server 2005.

Vedere anche

Riferimento

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