Bagikan melalui


TabletDeviceCollection.IsSynchronized Properti

Definisi

Mendapatkan nilai yang menunjukkan apakah akses ke koleksi disinkronkan (utas aman).

public:
 property bool IsSynchronized { bool get(); };
public bool IsSynchronized { get; }
member this.IsSynchronized : bool
Public ReadOnly Property IsSynchronized As Boolean

Nilai Properti

true jika akses ke koleksi disinkronkan (utas aman); jika tidak, false. Default adalah false.

Penerapan

Contoh

Contoh berikut menunjukkan IsSynchronized properti .

// Is the collection thread safe?        
if (!myTabletDeviceCollection.IsSynchronized)
{
    // If not, use SyncRoot to lock access
    lock (myTabletDeviceCollection.SyncRoot)
    {
        // work with collection
    }
}
'  Is the collection thread safe?
If Not myTabletDeviceCollection.IsSynchronized Then
    ' If not, use SyncRoot to lock access
    SyncLock myTabletDeviceCollection.SyncRoot
        ' work with collection
    End SyncLock
End If

Berlaku untuk