Variables.Locked Properti
Definisi
Penting
Beberapa informasi terkait produk prarilis yang dapat diubah secara signifikan sebelum dirilis. Microsoft tidak memberikan jaminan, tersirat maupun tersurat, sehubungan dengan informasi yang diberikan di sini.
Boolean yang menunjukkan apakah variabel dalam Variables koleksi dikunci.
public:
property bool Locked { bool get(); };
public bool Locked { get; }
member this.Locked : bool
Public ReadOnly Property Locked As Boolean
Nilai Properti
true menunjukkan bahwa koleksi dikunci. Nilai false menunjukkan bahwa koleksi tidak terkunci.
Contoh
Contoh kode berikut mengunci koleksi variabel saat GetVariables dipanggil. Contoh kemudian menentukan apakah koleksi dikunci dan, jika koleksi dikunci, memanggil 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();
}
}
}
}
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.LockForWrite("System::InteractiveMode")
variableDispenser.GetVariables( vars)
' Determine whether the variable collection is locked before unlocking.
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
Keterangan
Koleksi Variables berisi Locked properti yang menunjukkan apakah kumpulan variabel dispenser variabel dikunci (true
) atau tidak terkunci (false
). Alasan untuk meninjau properti ini adalah bahwa beberapa tugas secara eksplisit melepaskan kunci ke variabel yang mereka gunakan, dan memanggil Unlock dua kali melemparkan kesalahan. Oleh karena itu, Anda harus menggunakan Locked properti menentukan apakah koleksi yang dikunci dikunci sebelum memanggil Unlock.