共用方式為


TabletDeviceCollection.IsSynchronized 屬性

定義

取得值,這個值會指出是否同步處理對集合的存取 (具備執行緒安全)。

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

屬性值

如果同步處理對集合的存取 (具備執行緒安全),則為 true;否則為 false。 預設為 false

實作

範例

下列範例示範 IsSynchronized 屬性。

// 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

適用於