ActivityCollection.ICollection.SyncRoot Propriedade

Definição

Obtém um objeto que pode ser usado para sincronizar o acesso ao ICollection<T>.Gets an object that can be used to synchronize access to the ICollection<T>.

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

Valor da propriedade

Object

Um objeto que pode ser usado para sincronizar o acesso à ICollection<T>.An object that can be used to synchronize access to the ICollection<T>.

Implementações

Comentários

Para coleções cujo armazenamento subjacente não está disponível publicamente, a implementação esperada é retornar a instância atual.For collections whose underlying store is not publicly available, the expected implementation is to return the current instance. Observe que o ponteiro para a instância atual pode não ser suficiente para coleções que encapsulam outras coleções; Eles devem retornar a propriedade de coleção subjacente SyncRoot .Note that the pointer to the current instance might not be sufficient for collections that wrap other collections; those should return the underlying collection SyncRoot property.

A maioria das classes de coleção no System.Collections namespace também implementa um Synchronized método, que fornece um wrapper sincronizado em volta da coleção subjacente.Most collection classes in the System.Collections namespace also implement a Synchronized method, which provides a synchronized wrapper around the underlying collection. No entanto, as classes derivadas podem fornecer sua própria versão sincronizada da coleção usando a ICollection.SyncRoot propriedade.However, derived classes can provide their own synchronized version of the collection using the ICollection.SyncRoot property. O código de sincronização deve executar operações na ICollection.SyncRoot propriedade da coleção, não diretamente na coleção.The synchronizing code must perform operations on the ICollection.SyncRoot property of the collection, not directly on the collection. Isso garante a operação apropriada das coleções que são derivadas de outros objetos.This ensures proper operation of collections that are derived from other objects. Especificamente, ele mantém a sincronização adequada com outros threads que podem estar modificando simultaneamente a instância de coleção.Specifically, it maintains proper synchronization with other threads that might be simultaneously modifying the collection instance.

Aplica-se a