Export (0) Print
Expand All

IProducerConsumerCollection(Of T) Interface

Defines methods to manipulate thread-safe collections intended for producer/consumer usage. This interface provides a unified representation for producer/consumer collections so that higher level abstractions such as System.Collections.Concurrent.BlockingCollection(Of T) can use the collection as the underlying storage mechanism.

Namespace:  System.Collections.Concurrent
Assembly:  mscorlib (in mscorlib.dll)

'Declaration
Public Interface IProducerConsumerCollection(Of T) _
	Inherits IEnumerable(Of T), ICollection, IEnumerable

Type Parameters

T

Specifies the type of elements in the collection.

The IProducerConsumerCollection(Of T) type exposes the following members.

  NameDescription
Public propertyCountGets the number of elements contained in the ICollection. (Inherited from ICollection.)
Public propertyIsSynchronizedGets a value indicating whether access to the ICollection is synchronized (thread safe). (Inherited from ICollection.)
Public propertySyncRootGets an object that can be used to synchronize access to the ICollection. (Inherited from ICollection.)
Top

  NameDescription
Public methodCopyTo(T(), Int32)Copies the elements of the IProducerConsumerCollection(Of T) to an Array, starting at a specified index.
Public methodCopyTo(Array, Int32)Copies the elements of the ICollection to an Array, starting at a particular Array index. (Inherited from ICollection.)
Public methodGetEnumeratorReturns an enumerator that iterates through the collection. (Inherited from IEnumerable(Of T).)
Public methodToArrayCopies the elements contained in the IProducerConsumerCollection(Of T) to a new array.
Public methodTryAddAttempts to add an object to the IProducerConsumerCollection(Of T).
Public methodTryTakeAttempts to remove and return an object from the IProducerConsumerCollection(Of T).
Top

  NameDescription
Public Extension MethodAggregate(Of T)(Func(Of T, T, T))Overloaded. Applies an accumulator function over a sequence. (Defined by Enumerable.)
Public Extension MethodAggregate(Of T, TAccumulate)(TAccumulate, Func(Of TAccumulate, T, TAccumulate))Overloaded. Applies an accumulator function over a sequence. The specified seed value is used as the initial accumulator value. (Defined by Enumerable.)
Public Extension MethodAggregate(Of T, TAccumulate, TResult)(TAccumulate, Func(Of TAccumulate, T, TAccumulate), Func(Of TAccumulate, TResult))Overloaded. Applies an accumulator function over a sequence. The specified seed value is used as the initial accumulator value, and the specified function is used to select the result value. (Defined by Enumerable.)
Public Extension MethodAll(Of T)Determines whether all elements of a sequence satisfy a condition. (Defined by Enumerable.)
Public Extension MethodAny(Of T)Overloaded. Determines whether a sequence contains any elements. (Defined by Enumerable.)
Public Extension MethodAny(Of T)(Func(Of T, Boolean))Overloaded. Determines whether any element of a sequence satisfies a condition. (Defined by Enumerable.)
Public Extension MethodAsEnumerable(Of T)Returns the input typed as IEnumerable(Of T). (Defined by Enumerable.)
Public Extension MethodAsParallelOverloaded. Enables parallelization of a query. (Defined by ParallelEnumerable.)
Public Extension MethodAsParallel(Of T)Overloaded. Enables parallelization of a query. (Defined by ParallelEnumerable.)
Public Extension MethodAsQueryableOverloaded. Converts an IEnumerable to an IQueryable. (Defined by Queryable.)
Public Extension MethodAsQueryable(Of T)Overloaded. Converts a generic IEnumerable(Of T) to a generic IQueryable(Of T). (Defined by Queryable.)
Public Extension MethodAverage(Of T)(Func(Of T, Decimal))Overloaded. Computes the average of a sequence of Decimal values that are obtained by invoking a transform function on each element of the input sequence. (Defined by Enumerable.)
Public Extension MethodAverage(Of T)(Func(Of T, Nullable(Of Decimal)))Overloaded. Computes the average of a sequence of nullable Decimal values that are obtained by invoking a transform function on each element of the input sequence. (Defined by Enumerable.)
Public Extension MethodAverage(Of T)(Func(Of T, Double))Overloaded. Computes the average of a sequence of Double values that are obtained by invoking a transform function on each element of the input sequence. (Defined by Enumerable.)
Public Extension MethodAverage(Of T)(Func(Of T, Nullable(Of Double)))Overloaded. Computes the average of a sequence of nullable Double values that are obtained by invoking a transform function on each element of the input sequence. (Defined by Enumerable.)
Public Extension MethodAverage(Of T)(Func(Of T, Int32))Overloaded. Computes the average of a sequence of Int32 values that are obtained by invoking a transform function on each element of the input sequence. (Defined by Enumerable.)
Public Extension MethodAverage(Of T)(Func(Of T, Nullable(Of Int32)))Overloaded. Computes the average of a sequence of nullable Int32 values that are obtained by invoking a transform function on each element of the input sequence. (Defined by Enumerable.)
Public Extension MethodAverage(Of T)(Func(Of T, Int64))Overloaded. Computes the average of a sequence of Int64 values that are obtained by invoking a transform function on each element of the input sequence. (Defined by Enumerable.)
Public Extension MethodAverage(Of T)(Func(Of T, Nullable(Of Int64)))Overloaded. Computes the average of a sequence of nullable Int64 values that are obtained by invoking a transform function on each element of the input sequence. (Defined by Enumerable.)
Public Extension MethodAverage(Of T)(Func(Of T, Single))Overloaded. Computes the average of a sequence of Single values that are obtained by invoking a transform function on each element of the input sequence. (Defined by Enumerable.)
Public Extension MethodAverage(Of T)(Func(Of T, Nullable(Of Single)))Overloaded. Computes the average of a sequence of nullable Single values that are obtained by invoking a transform function on each element of the input sequence. (Defined by Enumerable.)
Public Extension MethodCast(Of TResult)Casts the elements of an IEnumerable to the specified type. (Defined by Enumerable.)
Public Extension MethodConcat(Of T)Concatenates two sequences. (Defined by Enumerable.)
Public Extension MethodContains(Of T)(T)Overloaded. Determines whether a sequence contains a specified element by using the default equality comparer. (Defined by Enumerable.)
Public Extension MethodContains(Of T)(T, IEqualityComparer(Of T))Overloaded. Determines whether a sequence contains a specified element by using a specified IEqualityComparer(Of T). (Defined by Enumerable.)
Public Extension MethodCount(Of T)Overloaded. Returns the number of elements in a sequence. (Defined by Enumerable.)
Public Extension MethodCount(Of T)(Func(Of T, Boolean))Overloaded. Returns a number that represents how many elements in the specified sequence satisfy a condition. (Defined by Enumerable.)
Public Extension MethodDefaultIfEmpty(Of T)Overloaded. Returns the elements of the specified sequence or the type parameter's default value in a singleton collection if the sequence is empty. (Defined by Enumerable.)
Public Extension MethodDefaultIfEmpty(Of T)(T)Overloaded. Returns the elements of the specified sequence or the specified value in a singleton collection if the sequence is empty. (Defined by Enumerable.)
Public Extension MethodDistinct(Of T)Overloaded. Returns distinct elements from a sequence by using the default equality comparer to compare values. (Defined by Enumerable.)
Public Extension MethodDistinct(Of T)(IEqualityComparer(Of T))Overloaded. Returns distinct elements from a sequence by using a specified IEqualityComparer(Of T) to compare values. (Defined by Enumerable.)
Public Extension MethodElementAt(Of T)Returns the element at a specified index in a sequence. (Defined by Enumerable.)
Public Extension MethodElementAtOrDefault(Of T)Returns the element at a specified index in a sequence or a default value if the index is out of range. (Defined by Enumerable.)
Public Extension MethodExcept(Of T)(IEnumerable(Of T))Overloaded. Produces the set difference of two sequences by using the default equality comparer to compare values. (Defined by Enumerable.)
Public Extension MethodExcept(Of T)(IEnumerable(Of T), IEqualityComparer(Of T))Overloaded. Produces the set difference of two sequences by using the specified IEqualityComparer(Of T) to compare values. (Defined by Enumerable.)
Public Extension MethodFirst(Of T)Overloaded. Returns the first element of a sequence. (Defined by Enumerable.)
Public Extension MethodFirst(Of T)(Func(Of T, Boolean))Overloaded. Returns the first element in a sequence that satisfies a specified condition. (Defined by Enumerable.)
Public Extension MethodFirstOrDefault(Of T)Overloaded. Returns the first element of a sequence, or a default value if the sequence contains no elements. (Defined by Enumerable.)
Public Extension MethodFirstOrDefault(Of T)(Func(Of T, Boolean))Overloaded. Returns the first element of the sequence that satisfies a condition or a default value if no such element is found. (Defined by Enumerable.)
Public Extension MethodGroupBy(Of T, TKey)(Func(Of T, TKey))Overloaded. Groups the elements of a sequence according to a specified key selector function. (Defined by Enumerable.)
Public Extension MethodGroupBy(Of T, TKey)(Func(Of T, TKey), IEqualityComparer(Of TKey))Overloaded. Groups the elements of a sequence according to a specified key selector function and compares the keys by using a specified comparer. (Defined by Enumerable.)
Public Extension MethodGroupBy(Of T, TKey, TElement)(Func(Of T, TKey), Func(Of T, TElement))Overloaded. Groups the elements of a sequence according to a specified key selector function and projects the elements for each group by using a specified function. (Defined by Enumerable.)
Public Extension MethodGroupBy(Of T, TKey, TResult)(Func(Of T, TKey), Func(Of TKey, IEnumerable(Of T), TResult))Overloaded. Groups the elements of a sequence according to a specified key selector function and creates a result value from each group and its key. (Defined by Enumerable.)
Public Extension MethodGroupBy(Of T, TKey, TElement)(Func(Of T, TKey), Func(Of T, TElement), IEqualityComparer(Of TKey))Overloaded. Groups the elements of a sequence according to a key selector function. The keys are compared by using a comparer and each group's elements are projected by using a specified function. (Defined by Enumerable.)
Public Extension MethodGroupBy(Of T, TKey, TResult)(Func(Of T, TKey), Func(Of TKey, IEnumerable(Of T), TResult), IEqualityComparer(Of TKey))Overloaded. Groups the elements of a sequence according to a specified key selector function and creates a result value from each group and its key. The keys are compared by using a specified comparer. (Defined by Enumerable.)
Public Extension MethodGroupBy(Of T, TKey, TElement, TResult)(Func(Of T, TKey), Func(Of T, TElement), Func(Of TKey, IEnumerable(Of TElement), TResult))Overloaded. Groups the elements of a sequence according to a specified key selector function and creates a result value from each group and its key. The elements of each group are projected by using a specified function. (Defined by Enumerable.)
Public Extension MethodGroupBy(Of T, TKey, TElement, TResult)(Func(Of T, TKey), Func(Of T, TElement), Func(Of TKey, IEnumerable(Of TElement), TResult), IEqualityComparer(Of TKey))Overloaded. Groups the elements of a sequence according to a specified key selector function and creates a result value from each group and its key. Key values are compared by using a specified comparer, and the elements of each group are projected by using a specified function. (Defined by Enumerable.)
Public Extension MethodGroupJoin(Of T, TInner, TKey, TResult)(IEnumerable(Of TInner), Func(Of T, TKey), Func(Of TInner, TKey), Func(Of T, IEnumerable(Of TInner), TResult))Overloaded. Correlates the elements of two sequences based on equality of keys and groups the results. The default equality comparer is used to compare keys. (Defined by Enumerable.)
Public Extension MethodGroupJoin(Of T, TInner, TKey, TResult)(IEnumerable(Of TInner), Func(Of T, TKey), Func(Of TInner, TKey), Func(Of T, IEnumerable(Of TInner), TResult), IEqualityComparer(Of TKey))Overloaded. Correlates the elements of two sequences based on key equality and groups the results. A specified IEqualityComparer(Of T) is used to compare keys. (Defined by Enumerable.)
Public Extension MethodIntersect(Of T)(IEnumerable(Of T))Overloaded. Produces the set intersection of two sequences by using the default equality comparer to compare values. (Defined by Enumerable.)
Public Extension MethodIntersect(Of T)(IEnumerable(Of T), IEqualityComparer(Of T))Overloaded. Produces the set intersection of two sequences by using the specified IEqualityComparer(Of T) to compare values. (Defined by Enumerable.)
Public Extension MethodJoin(Of T, TInner, TKey, TResult)(IEnumerable(Of TInner), Func(Of T, TKey), Func(Of TInner, TKey), Func(Of T, TInner, TResult))Overloaded. Correlates the elements of two sequences based on matching keys. The default equality comparer is used to compare keys. (Defined by Enumerable.)
Public Extension MethodJoin(Of T, TInner, TKey, TResult)(IEnumerable(Of TInner), Func(Of T, TKey), Func(Of TInner, TKey), Func(Of T, TInner, TResult), IEqualityComparer(Of TKey))Overloaded. Correlates the elements of two sequences based on matching keys. A specified IEqualityComparer(Of T) is used to compare keys. (Defined by Enumerable.)
Public Extension MethodLast(Of T)Overloaded. Returns the last element of a sequence. (Defined by Enumerable.)
Public Extension MethodLast(Of T)(Func(Of T, Boolean))Overloaded. Returns the last element of a sequence that satisfies a specified condition. (Defined by Enumerable.)
Public Extension MethodLastOrDefault(Of T)Overloaded. Returns the last element of a sequence, or a default value if the sequence contains no elements. (Defined by Enumerable.)
Public Extension MethodLastOrDefault(Of T)(Func(Of T, Boolean))Overloaded. Returns the last element of a sequence that satisfies a condition or a default value if no such element is found. (Defined by Enumerable.)
Public Extension MethodLongCount(Of T)Overloaded. Returns an Int64 that represents the total number of elements in a sequence. (Defined by Enumerable.)
Public Extension MethodLongCount(Of T)(Func(Of T, Boolean))Overloaded. Returns an Int64 that represents how many elements in a sequence satisfy a condition. (Defined by Enumerable.)
Public Extension MethodMax(Of T)Overloaded. Returns the maximum value in a generic sequence. (Defined by Enumerable.)
Public Extension MethodMax(Of T)(Func(Of T, Decimal))Overloaded. Invokes a transform function on each element of a sequence and returns the maximum Decimal value. (Defined by Enumerable.)
Public Extension MethodMax(Of T)(Func(Of T, Nullable(Of Decimal)))Overloaded. Invokes a transform function on each element of a sequence and returns the maximum nullable Decimal value. (Defined by Enumerable.)
Public Extension MethodMax(Of T)(Func(Of T, Double))Overloaded. Invokes a transform function on each element of a sequence and returns the maximum Double value. (Defined by Enumerable.)
Public Extension MethodMax(Of T)(Func(Of T, Nullable(Of Double)))Overloaded. Invokes a transform function on each element of a sequence and returns the maximum nullable Double value. (Defined by Enumerable.)
Public Extension MethodMax(Of T)(Func(Of T, Int32))Overloaded. Invokes a transform function on each element of a sequence and returns the maximum Int32 value. (Defined by Enumerable.)
Public Extension MethodMax(Of T)(Func(Of T, Nullable(Of Int32)))Overloaded. Invokes a transform function on each element of a sequence and returns the maximum nullable Int32 value. (Defined by Enumerable.)
Public Extension MethodMax(Of T)(Func(Of T, Int64))Overloaded. Invokes a transform function on each element of a sequence and returns the maximum Int64 value. (Defined by Enumerable.)
Public Extension MethodMax(Of T)(Func(Of T, Nullable(Of Int64)))Overloaded. Invokes a transform function on each element of a sequence and returns the maximum nullable Int64 value. (Defined by Enumerable.)
Public Extension MethodMax(Of T)(Func(Of T, Single))Overloaded. Invokes a transform function on each element of a sequence and returns the maximum Single value. (Defined by Enumerable.)
Public Extension MethodMax(Of T)(Func(Of T, Nullable(Of Single)))Overloaded. Invokes a transform function on each element of a sequence and returns the maximum nullable Single value. (Defined by Enumerable.)
Public Extension MethodMax(Of T, TResult)(Func(Of T, TResult))Overloaded. Invokes a transform function on each element of a generic sequence and returns the maximum resulting value. (Defined by Enumerable.)
Public Extension MethodMin(Of T)Overloaded. Returns the minimum value in a generic sequence. (Defined by Enumerable.)
Public Extension MethodMin(Of T)(Func(Of T, Decimal))Overloaded. Invokes a transform function on each element of a sequence and returns the minimum Decimal value. (Defined by Enumerable.)
Public Extension MethodMin(Of T)(Func(Of T, Nullable(Of Decimal)))Overloaded. Invokes a transform function on each element of a sequence and returns the minimum nullable Decimal value. (Defined by Enumerable.)
Public Extension MethodMin(Of T)(Func(Of T, Double))Overloaded. Invokes a transform function on each element of a sequence and returns the minimum Double value. (Defined by Enumerable.)
Public Extension MethodMin(Of T)(Func(Of T, Nullable(Of Double)))Overloaded. Invokes a transform function on each element of a sequence and returns the minimum nullable Double value. (Defined by Enumerable.)
Public Extension MethodMin(Of T)(Func(Of T, Int32))Overloaded. Invokes a transform function on each element of a sequence and returns the minimum Int32 value. (Defined by Enumerable.)
Public Extension MethodMin(Of T)(Func(Of T, Nullable(Of Int32)))Overloaded. Invokes a transform function on each element of a sequence and returns the minimum nullable Int32 value. (Defined by Enumerable.)
Public Extension MethodMin(Of T)(Func(Of T, Int64))Overloaded. Invokes a transform function on each element of a sequence and returns the minimum Int64 value. (Defined by Enumerable.)
Public Extension MethodMin(Of T)(Func(Of T, Nullable(Of Int64)))Overloaded. Invokes a transform function on each element of a sequence and returns the minimum nullable Int64 value. (Defined by Enumerable.)
Public Extension MethodMin(Of T)(Func(Of T, Single))Overloaded. Invokes a transform function on each element of a sequence and returns the minimum Single value. (Defined by Enumerable.)
Public Extension MethodMin(Of T)(Func(Of T, Nullable(Of Single)))Overloaded. Invokes a transform function on each element of a sequence and returns the minimum nullable Single value. (Defined by Enumerable.)
Public Extension MethodMin(Of T, TResult)(Func(Of T, TResult))Overloaded. Invokes a transform function on each element of a generic sequence and returns the minimum resulting value. (Defined by Enumerable.)
Public Extension MethodOfType(Of TResult)Filters the elements of an IEnumerable based on a specified type. (Defined by Enumerable.)
Public Extension MethodOrderBy(Of T, TKey)(Func(Of T, TKey))Overloaded. Sorts the elements of a sequence in ascending order according to a key. (Defined by Enumerable.)
Public Extension MethodOrderBy(Of T, TKey)(Func(Of T, TKey), IComparer(Of TKey))Overloaded. Sorts the elements of a sequence in ascending order by using a specified comparer. (Defined by Enumerable.)
Public Extension MethodOrderByDescending(Of T, TKey)(Func(Of T, TKey))Overloaded. Sorts the elements of a sequence in descending order according to a key. (Defined by Enumerable.)
Public Extension MethodOrderByDescending(Of T, TKey)(Func(Of T, TKey), IComparer(Of TKey))Overloaded. Sorts the elements of a sequence in descending order by using a specified comparer. (Defined by Enumerable.)
Public Extension MethodReverse(Of T)Inverts the order of the elements in a sequence. (Defined by Enumerable.)
Public Extension MethodSelect(Of T, TResult)(Func(Of T, TResult))Overloaded. Projects each element of a sequence into a new form. (Defined by Enumerable.)
Public Extension MethodSelect(Of T, TResult)(Func(Of T, Int32, TResult))Overloaded. Projects each element of a sequence into a new form by incorporating the element's index. (Defined by Enumerable.)
Public Extension MethodSelectMany(Of T, TResult)(Func(Of T, IEnumerable(Of TResult)))Overloaded. Projects each element of a sequence to an IEnumerable(Of T) and flattens the resulting sequences into one sequence. (Defined by Enumerable.)
Public Extension MethodSelectMany(Of T, TResult)(Func(Of T, Int32, IEnumerable(Of TResult)))Overloaded. Projects each element of a sequence to an IEnumerable(Of T), and flattens the resulting sequences into one sequence. The index of each source element is used in the projected form of that element. (Defined by Enumerable.)
Public Extension MethodSelectMany(Of T, TCollection, TResult)(Func(Of T, Int32, IEnumerable(Of TCollection)), Func(Of T, TCollection, TResult))Overloaded. Projects each element of a sequence to an IEnumerable(Of T), flattens the resulting sequences into one sequence, and invokes a result selector function on each element therein. The index of each source element is used in the intermediate projected form of that element. (Defined by Enumerable.)
Public Extension MethodSelectMany(Of T, TCollection, TResult)(Func(Of T, IEnumerable(Of TCollection)), Func(Of T, TCollection, TResult))Overloaded. Projects each element of a sequence to an IEnumerable(Of T), flattens the resulting sequences into one sequence, and invokes a result selector function on each element therein. (Defined by Enumerable.)
Public Extension MethodSequenceEqual(Of T)(IEnumerable(Of T))Overloaded. Determines whether two sequences are equal by comparing the elements by using the default equality comparer for their type. (Defined by Enumerable.)
Public Extension MethodSequenceEqual(Of T)(IEnumerable(Of T), IEqualityComparer(Of T))Overloaded. Determines whether two sequences are equal by comparing their elements by using a specified IEqualityComparer(Of T). (Defined by Enumerable.)
Public Extension MethodSingle(Of T)Overloaded. Returns the only element of a sequence, and throws an exception if there is not exactly one element in the sequence. (Defined by Enumerable.)
Public Extension MethodSingle(Of T)(Func(Of T, Boolean))Overloaded. Returns the only element of a sequence that satisfies a specified condition, and throws an exception if more than one such element exists. (Defined by Enumerable.)
Public Extension MethodSingleOrDefault(Of T)Overloaded. Returns the only element of a sequence, or a default value if the sequence is empty; this method throws an exception if there is more than one element in the sequence. (Defined by Enumerable.)
Public Extension MethodSingleOrDefault(Of T)(Func(Of T, Boolean))Overloaded. Returns the only element of a sequence that satisfies a specified condition or a default value if no such element exists; this method throws an exception if more than one element satisfies the condition. (Defined by Enumerable.)
Public Extension MethodSkip(Of T)Bypasses a specified number of elements in a sequence and then returns the remaining elements. (Defined by Enumerable.)
Public Extension MethodSkipWhile(Of T)(Func(Of T, Boolean))Overloaded. Bypasses elements in a sequence as long as a specified condition is true and then returns the remaining elements. (Defined by Enumerable.)
Public Extension MethodSkipWhile(Of T)(Func(Of T, Int32, Boolean))Overloaded. Bypasses elements in a sequence as long as a specified condition is true and then returns the remaining elements. The element's index is used in the logic of the predicate function. (Defined by Enumerable.)
Public Extension MethodSum(Of T)(Func(Of T, Decimal))Overloaded. Computes the sum of the sequence of Decimal values that are obtained by invoking a transform function on each element of the input sequence. (Defined by Enumerable.)
Public Extension MethodSum(Of T)(Func(Of T, Nullable(Of Decimal)))Overloaded. Computes the sum of the sequence of nullable Decimal values that are obtained by invoking a transform function on each element of the input sequence. (Defined by Enumerable.)
Public Extension MethodSum(Of T)(Func(Of T, Double))Overloaded. Computes the sum of the sequence of Double values that are obtained by invoking a transform function on each element of the input sequence. (Defined by Enumerable.)
Public Extension MethodSum(Of T)(Func(Of T, Nullable(Of Double)))Overloaded. Computes the sum of the sequence of nullable Double values that are obtained by invoking a transform function on each element of the input sequence. (Defined by Enumerable.)
Public Extension MethodSum(Of T)(Func(Of T, Int32))Overloaded. Computes the sum of the sequence of Int32 values that are obtained by invoking a transform function on each element of the input sequence. (Defined by Enumerable.)
Public Extension MethodSum(Of T)(Func(Of T, Nullable(Of Int32)))Overloaded. Computes the sum of the sequence of nullable Int32 values that are obtained by invoking a transform function on each element of the input sequence. (Defined by Enumerable.)
Public Extension MethodSum(Of T)(Func(Of T, Int64))Overloaded. Computes the sum of the sequence of Int64 values that are obtained by invoking a transform function on each element of the input sequence. (Defined by Enumerable.)
Public Extension MethodSum(Of T)(Func(Of T, Nullable(Of Int64)))Overloaded. Computes the sum of the sequence of nullable Int64 values that are obtained by invoking a transform function on each element of the input sequence. (Defined by Enumerable.)
Public Extension MethodSum(Of T)(Func(Of T, Single))Overloaded. Computes the sum of the sequence of Single values that are obtained by invoking a transform function on each element of the input sequence. (Defined by Enumerable.)
Public Extension MethodSum(Of T)(Func(Of T, Nullable(Of Single)))Overloaded. Computes the sum of the sequence of nullable Single values that are obtained by invoking a transform function on each element of the input sequence. (Defined by Enumerable.)
Public Extension MethodTake(Of T)Returns a specified number of contiguous elements from the start of a sequence. (Defined by Enumerable.)
Public Extension MethodTakeWhile(Of T)(Func(Of T, Boolean))Overloaded. Returns elements from a sequence as long as a specified condition is true. (Defined by Enumerable.)
Public Extension MethodTakeWhile(Of T)(Func(Of T, Int32, Boolean))Overloaded. Returns elements from a sequence as long as a specified condition is true. The element's index is used in the logic of the predicate function. (Defined by Enumerable.)
Public Extension MethodToArray(Of T)Creates an array from a IEnumerable(Of T). (Defined by Enumerable.)
Public Extension MethodToDictionary(Of T, TKey)(Func(Of T, TKey))Overloaded. Creates a Dictionary(Of TKey, TValue) from an IEnumerable(Of T) according to a specified key selector function. (Defined by Enumerable.)
Public Extension MethodToDictionary(Of T, TKey)(Func(Of T, TKey), IEqualityComparer(Of TKey))Overloaded. Creates a Dictionary(Of TKey, TValue) from an IEnumerable(Of T) according to a specified key selector function and key comparer. (Defined by Enumerable.)
Public Extension MethodToDictionary(Of T, TKey, TElement)(Func(Of T, TKey), Func(Of T, TElement))Overloaded. Creates a Dictionary(Of TKey, TValue) from an IEnumerable(Of T) according to specified key selector and element selector functions. (Defined by Enumerable.)
Public Extension MethodToDictionary(Of T, TKey, TElement)(Func(Of T, TKey), Func(Of T, TElement), IEqualityComparer(Of TKey))Overloaded. Creates a Dictionary(Of TKey, TValue) from an IEnumerable(Of T) according to a specified key selector function, a comparer, and an element selector function. (Defined by Enumerable.)
Public Extension MethodToList(Of T)Creates a List(Of T) from an IEnumerable(Of T). (Defined by Enumerable.)
Public Extension MethodToLookup(Of T, TKey)(Func(Of T, TKey))Overloaded. Creates a Lookup(Of TKey, TElement) from an IEnumerable(Of T) according to a specified key selector function. (Defined by Enumerable.)
Public Extension MethodToLookup(Of T, TKey)(Func(Of T, TKey), IEqualityComparer(Of TKey))Overloaded. Creates a Lookup(Of TKey, TElement) from an IEnumerable(Of T) according to a specified key selector function and key comparer. (Defined by Enumerable.)
Public Extension MethodToLookup(Of T, TKey, TElement)(Func(Of T, TKey), Func(Of T, TElement))Overloaded. Creates a Lookup(Of TKey, TElement) from an IEnumerable(Of T) according to specified key selector and element selector functions. (Defined by Enumerable.)
Public Extension MethodToLookup(Of T, TKey, TElement)(Func(Of T, TKey), Func(Of T, TElement), IEqualityComparer(Of TKey))Overloaded. Creates a Lookup(Of TKey, TElement) from an IEnumerable(Of T) according to a specified key selector function, a comparer and an element selector function. (Defined by Enumerable.)
Public Extension MethodUnion(Of T)(IEnumerable(Of T))Overloaded. Produces the set union of two sequences by using the default equality comparer. (Defined by Enumerable.)
Public Extension MethodUnion(Of T)(IEnumerable(Of T), IEqualityComparer(Of T))Overloaded. Produces the set union of two sequences by using a specified IEqualityComparer(Of T). (Defined by Enumerable.)
Public Extension MethodWhere(Of T)(Func(Of T, Boolean))Overloaded. Filters a sequence of values based on a predicate. (Defined by Enumerable.)
Public Extension MethodWhere(Of T)(Func(Of T, Int32, Boolean))Overloaded. Filters a sequence of values based on a predicate. Each element's index is used in the logic of the predicate function. (Defined by Enumerable.)
Public Extension MethodZip(Of T, TSecond, TResult)Applies a specified function to the corresponding elements of two sequences, producing a sequence of the results. (Defined by Enumerable.)
Top

The following example shows a stack data structure that implements System.Collections.Concurrent.IProducerConsumerCollection(Of T).


Imports System.Collections.Concurrent

Module IProdCon
    ' Sample implementation of IProducerConsumerCollection(T) -- in this case,
    ' a thread-safe stack.
    Public Class SafeStack(Of T)
        Implements IProducerConsumerCollection(Of T)

        ' Used for enforcing thread-safety
        Private m_lockObject As New Object()

        ' We'll use a regular old Stack for our core operations
        Private m_sequentialStack As Stack(Of T) = Nothing

        '
        ' Constructors
        '
        Public Sub New()
            m_sequentialStack = New Stack(Of T)()
        End Sub

        Public Sub New(ByVal collection As IEnumerable(Of T))
            m_sequentialStack = New Stack(Of T)(collection)
        End Sub

        '
        ' Safe Push/Pop support
        '
        Public Sub Push(ByVal item As T)
            SyncLock m_lockObject
                m_sequentialStack.Push(item)
            End SyncLock
        End Sub

        Public Function TryPop(ByRef item As T) As Boolean
            Dim rval As Boolean = True
            SyncLock m_lockObject
                If m_sequentialStack.Count = 0 Then
                    item = Nothing
                    rval = False
                Else
                    item = m_sequentialStack.Pop()
                End If
            End SyncLock
            Return rval
        End Function

        '
        ' IProducerConsumerCollection(T) support
        '
        Public Function TryTake(ByRef item As T) As Boolean Implements IProducerConsumerCollection(Of T).TryTake
            Return TryPop(item)
        End Function

        Public Function TryAdd(ByVal item As T) As Boolean Implements IProducerConsumerCollection(Of T).TryAdd
            Push(item)
            ' Push doesn't fail
            Return True
        End Function

        Public Function ToArray() As T() Implements IProducerConsumerCollection(Of T).ToArray
            Dim rval As T() = Nothing
            SyncLock m_lockObject
                rval = m_sequentialStack.ToArray()
            End SyncLock
            Return rval
        End Function

        Public Sub CopyTo(ByVal array As T(), ByVal index As Integer) Implements IProducerConsumerCollection(Of T).CopyTo
            SyncLock m_lockObject
                m_sequentialStack.CopyTo(array, index)
            End SyncLock
        End Sub



        '
        ' Support for IEnumerable(T)
        '
        Public Function GetEnumerator() As IEnumerator(Of T) Implements IEnumerable(Of T).GetEnumerator
            ' The performance here will be unfortunate for large stacks,
            ' but thread-safety is effectively implemented.
            Dim stackCopy As Stack(Of T) = Nothing
            SyncLock m_lockObject
                stackCopy = New Stack(Of T)(m_sequentialStack)
            End SyncLock
            Return stackCopy.GetEnumerator()
        End Function


        '
        ' Support for IEnumerable
        '
        Private Function GetEnumerator2() As IEnumerator Implements IEnumerable.GetEnumerator
            Return DirectCast(Me, IEnumerable(Of T)).GetEnumerator()
        End Function

        ' 
        ' Support for ICollection
        '
        Public ReadOnly Property IsSynchronized() As Boolean Implements ICollection.IsSynchronized
            Get
                Return True
            End Get
        End Property

        Public ReadOnly Property SyncRoot() As Object Implements ICollection.SyncRoot
            Get
                Return m_lockObject
            End Get
        End Property

        Public ReadOnly Property Count() As Integer Implements ICollection.Count
            Get
                Return m_sequentialStack.Count
            End Get
        End Property

        Public Sub CopyTo(ByVal array As Array, ByVal index As Integer) Implements ICollection.CopyTo
            SyncLock m_lockObject
                DirectCast(m_sequentialStack, ICollection).CopyTo(array, index)
            End SyncLock
        End Sub
    End Class

    ' Test our implementation of IProducerConsumerCollection(T)
    ' Demonstrates:
    ' IPCC(T).TryAdd()
    ' IPCC(T).TryTake()
    ' IPCC(T).CopyTo()
    Private Sub TestSafeStack()
        Dim stack As New SafeStack(Of Integer)()
        Dim ipcc As IProducerConsumerCollection(Of Integer) = DirectCast(stack, IProducerConsumerCollection(Of Integer))

        ' Test Push()/TryAdd()
        stack.Push(10)
        Console.WriteLine("Pushed 10")
        ipcc.TryAdd(20)
        Console.WriteLine("IPCC.TryAdded 20")
        stack.Push(15)
        Console.WriteLine("Pushed 15")

        Dim testArray As Integer() = New Integer(2) {}

        ' Try CopyTo() within boundaries
        Try
            ipcc.CopyTo(testArray, 0)
            Console.WriteLine("CopyTo() within boundaries worked, as expected")
        Catch e As Exception
            Console.WriteLine("CopyTo() within boundaries unexpectedly threw an exception: {0}", e.Message)
        End Try

        ' Try CopyTo() that overflows
        Try
            ipcc.CopyTo(testArray, 1)
            Console.WriteLine("CopyTo() with index overflow worked, and it SHOULD NOT HAVE")
        Catch e As Exception
            Console.WriteLine("CopyTo() with index overflow threw an exception, as expected: {0}", e.Message)
        End Try

        ' Test enumeration
        Console.Write("Enumeration (should be three items): ")
        For Each item As Integer In stack
            Console.Write("{0} ", item)
        Next
        Console.WriteLine("")

        ' Test TryPop()
        Dim popped As Integer = 0
        If stack.TryPop(popped) Then
            Console.WriteLine("Successfully popped {0}", popped)
        Else
            Console.WriteLine("FAILED to pop!!")
        End If

        ' Test Count
        Console.WriteLine("stack count is {0}, should be 2", stack.Count)

        ' Test TryTake()
        If ipcc.TryTake(popped) Then
            Console.WriteLine("Successfully IPCC-TryTaked {0}", popped)
        Else
            Console.WriteLine("FAILED to IPCC.TryTake!!")
        End If
    End Sub

    Sub Main()
        TestSafeStack()

        ' Keep the console window open in debug mode
        Console.WriteLine("Press any key to exit.")
        Console.ReadKey()

    End Sub

End Module


.NET Framework

Supported in: 4

.NET Framework Client Profile

Supported in: 4

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Community Additions

ADD
Show:
© 2015 Microsoft