ArrangedElementCollection.GetEnumerator Metoda
Definicja
Zwraca moduł wyliczający dla całej kolekcji.Returns an enumerator for the entire collection.
public:
virtual System::Collections::IEnumerator ^ GetEnumerator();
public virtual System.Collections.IEnumerator GetEnumerator ();
abstract member GetEnumerator : unit -> System.Collections.IEnumerator
override this.GetEnumerator : unit -> System.Collections.IEnumerator
Public Overridable Function GetEnumerator () As IEnumerator
Zwraca
IEnumeratorDla całej kolekcji.An IEnumerator for the entire collection.
Implementuje
Uwagi
Zazwyczaj moduł wyliczający nie ma wyłącznego dostępu do kolekcji; w związku z tym Wyliczanie za pomocą kolekcji nie jest w sposób wewnętrznie bezpieczny dla wątków.Typically the enumerator does not have exclusive access to the collection; therefore, enumerating through a collection is intrinsically not a thread-safe procedure. Nawet w przypadku synchronizacji kolekcji inne wątki mogą nadal modyfikować kolekcję, co powoduje zgłoszenie wyjątku przez moduł wyliczający.Even when a collection is synchronized, other threads could still modify the collection, which causes the enumerator to throw an exception. Aby zagwarantować bezpieczeństwo wątków podczas wyliczania, można wykonać jedną z następujących strategii:To guarantee thread safety during enumeration, you can follow one of the following strategies:
Zablokuj kolekcję podczas całego wyliczenia przy użyciu Monitor .Lock the collection during the entire enumeration using a Monitor.
Przechwytuj i obsługuj wyjątki wynikające ze zmian wprowadzonych przez inne wątki.Catch and handle the exceptions that result from changes made by other threads.