AudienceCollection.GetEnumerator Method
Returns an enumerator that iterates through the AudienceCollection object.
Namespace: Microsoft.Office.Server.Audience
Assembly: Microsoft.Office.Server.UserProfiles (in Microsoft.Office.Server.UserProfiles.dll)
Syntax
'Declaration
Public Function GetEnumerator As IEnumerator
'Usage
Dim instance As AudienceCollection
Dim returnValue As IEnumerator
returnValue = instance.GetEnumerator()
public IEnumerator GetEnumerator()
Return Value
Type: System.Collections.IEnumerator
A System.Collections.IEnumerator that represents an enumerator that iterates through the collection.
Implements
Remarks
The enumerator returned by GetEnumerator does not have exclusive access to the collection; therefore, enumerating through a collection is intrinsically not a thread-safe procedure. Even when a collection is synchronized, other threads can still modify the collection, which causes the enumerator to throw an exception. To ensure thread safety during enumeration, you can either lock the collection during the entire enumeration or catch the exceptions resulting from changes made by other threads.