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

适用于