HttpStaticObjectsCollection.SyncRoot 属性

定义

获取可用于同步对集合的访问的对象。Gets an object that can be used to synchronize access to the collection.

public:
 property System::Object ^ SyncRoot { System::Object ^ get(); };
public object SyncRoot { get; }
member this.SyncRoot : obj
Public ReadOnly Property SyncRoot As Object

属性值

实现

示例

下面的示例创建一个对象,该对象用于同步对HttpStaticObjectsCollection的访问。The following example creates an object used to synchronize access to the HttpStaticObjectsCollection.

Object MySyncObject = Application.StaticObjects.SyncRoot;
   
Dim MySyncObject As Object = Application.StaticObjects.SyncRoot
   

注解

程序代码通常应在集合的上SyncRoot执行同步操作,而不是直接在集合本身上执行。Program code should generally perform synchronized operations on the SyncRoot of a collection, not directly on the collection itself. 这样可确保对从其他对象派生的集合正确地执行操作。This ensures proper operation of collections that are derived from other objects. 具体而言,它与可能同时修改集合对象的其他线程保持正确的同步。Specifically, it maintains proper synchronization with other threads that might be simultaneously modifying the collection object.

此实现中返回的对象HttpStaticObjectsCollection本身就是。The object returned in this implementation is the HttpStaticObjectsCollection itself.

适用于