System Namespace

[image]

.NET Framework Class Library
System Namespace
Send Feedback

Classes

Class | Description
AggregateException | Represents one or more errors that occur during application execution.
Lazy<(Of <(T>)>) | Provides support for lazy initialization.

Delegates

Delegate | Description
Func_<(Of <(T1, T2, T3, T4, T5, TResult>)>) | Encapsulates a method that has five parameters and returns a value of the type specified by the TResult parameter.
Send feedback on this topic to Microsoft.


AggregateException Class

[image]

.NET Framework Class Library
AggregateException Class
See Also Send Feedback

Represents one or more errors that occur during application execution.

Namespace: System
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
<SerializableAttribute> _
Public Class AggregateException _
    Inherits Exception
C#
[SerializableAttribute]
public class AggregateException : Exception

Remarks

AggregateException is used to consolidate multiple failures into a single, throwable exception object.

Inheritance Hierarchy

System..::.Object
System..::.Exception
System..::.AggregateException

See Also

System Namespace


AggregateException Constructor

[image] [image]

.NET Framework Class Library
AggregateException Constructor
AggregateException Class See Also Send Feedback

Overload List

Name | Description
AggregateException()()() | Initializes a new instance of the AggregateException class.
AggregateException(IEnumerable<(Of <(Exception>)>)) | Initializes a new instance of the AggregateException class with references to the inner exceptions that are the cause of this exception.
AggregateException(array<Exception>[]()[]) | Initializes a new instance of the AggregateException class with references to the inner exceptions that are the cause of this exception.
AggregateException(String) | Initializes a new instance of the AggregateException class with a specified error message.
AggregateException(SerializationInfo, StreamingContext) | Initializes a new instance of the AggregateException class with serialized data.
AggregateException(String, IEnumerable<(Of <(Exception>)>)) | Initializes a new instance of the AggregateException class with a specified error message and references to the inner exceptions that are the cause of this exception.
AggregateException(String, Exception) | Initializes a new instance of the AggregateException class with a specified error message and a reference to the inner exception that is the cause of this exception.
AggregateException(String, array<Exception>[]()[]) | Initializes a new instance of the AggregateException class with a specified error message and references to the inner exceptions that are the cause of this exception.

See Also

AggregateException Class
System Namespace


AggregateException Constructor

[image]

.NET Framework Class Library
AggregateException Constructor
AggregateException Class See Also Send Feedback

Initializes a new instance of the AggregateException class.

Namespace: System
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Sub New
C#
public AggregateException()

See Also

AggregateException Class
AggregateException Overload
System Namespace


AggregateException Constructor (IEnumerable(Exception))

[image]

.NET Framework Class Library
AggregateException Constructor (IEnumerable<(Of <(Exception>)>))
AggregateException Class See Also Send Feedback

Initializes a new instance of the AggregateException class with references to the inner exceptions that are the cause of this exception.

Namespace: System
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Sub New ( _
    innerExceptions As IEnumerable(Of Exception) _
)
C#
public AggregateException(
    IEnumerable<Exception> innerExceptions
)

Parameters

innerExceptions
Type: System.Collections.Generic..::.IEnumerable<(Of <(Exception>)>)
The exceptions that are the cause of the current exception.

Exceptions

Exception | Condition
System..::.ArgumentNullException | The innerExceptions argument is null.
System..::.ArgumentException | An element of innerExceptions is null.

See Also

AggregateException Class
AggregateException Overload
System Namespace


AggregateException Constructor (Exception[])

[image]

.NET Framework Class Library
AggregateException Constructor (array<Exception>[]()[])
AggregateException Class See Also Send Feedback

Initializes a new instance of the AggregateException class with references to the inner exceptions that are the cause of this exception.

Namespace: System
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Sub New ( _
    ParamArray innerExceptions As Exception() _
)
C#
public AggregateException(
    params Exception[] innerExceptions
)

Parameters

innerExceptions
Type: array< System..::.Exception >[]()[]
The exceptions that are the cause of the current exception.

Exceptions

Exception | Condition
System..::.ArgumentNullException | The innerExceptions argument is null.
System..::.ArgumentException | An element of innerExceptions is null.

See Also

AggregateException Class
AggregateException Overload
System Namespace


AggregateException Constructor (String)

[image]

.NET Framework Class Library
AggregateException Constructor (String)
AggregateException Class See Also Send Feedback

Initializes a new instance of the AggregateException class with a specified error message.

Namespace: System
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Sub New ( _
    message As String _
)
C#
public AggregateException(
    string message
)

Parameters

message
Type: System..::.String
The error message that explains the reason for the exception.

See Also

AggregateException Class
AggregateException Overload
System Namespace


AggregateException Constructor (SerializationInfo, StreamingContext)

[image]

.NET Framework Class Library
AggregateException Constructor (SerializationInfo, StreamingContext)
AggregateException Class See Also Send Feedback

Initializes a new instance of the AggregateException class with serialized data.

Namespace: System
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Protected Sub New ( _
    info As SerializationInfo, _
    context As StreamingContext _
)
C#
protected AggregateException(
    SerializationInfo info,
    StreamingContext context
)

Parameters

info
Type: System.Runtime.Serialization..::.SerializationInfo
The SerializationInfo that holds the serialized object data about the exception being thrown.
context
Type: System.Runtime.Serialization..::.StreamingContext
The StreamingContext that contains contextual information about the source or destination.

Exceptions

Exception | Condition
System..::.ArgumentNullException | The info argument is null.
System.Runtime.Serialization..::.SerializationException | The exception could not be deserialized correctly.

See Also

AggregateException Class
AggregateException Overload
System Namespace


AggregateException Constructor (String, IEnumerable(Exception))

[image]

.NET Framework Class Library
AggregateException Constructor (String, IEnumerable<(Of <(Exception>)>))
AggregateException Class See Also Send Feedback

Initializes a new instance of the AggregateException class with a specified error message and references to the inner exceptions that are the cause of this exception.

Namespace: System
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Sub New ( _
    message As String, _
    innerExceptions As IEnumerable(Of Exception) _
)
C#
public AggregateException(
    string message,
    IEnumerable<Exception> innerExceptions
)

Parameters

message
Type: System..::.String
The error message that explains the reason for the exception.
innerExceptions
Type: System.Collections.Generic..::.IEnumerable<(Of <(Exception>)>)
The exceptions that are the cause of the current exception.

Exceptions

Exception | Condition
System..::.ArgumentNullException | The innerExceptions argument is null.
System..::.ArgumentException | An element of innerExceptions is null.

See Also

AggregateException Class
AggregateException Overload
System Namespace


AggregateException Constructor (String, Exception)

[image]

.NET Framework Class Library
AggregateException Constructor (String, Exception)
AggregateException Class See Also Send Feedback

Initializes a new instance of the AggregateException class with a specified error message and a reference to the inner exception that is the cause of this exception.

Namespace: System
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Sub New ( _
    message As String, _
    innerException As Exception _
)
C#
public AggregateException(
    string message,
    Exception innerException
)

Parameters

message
Type: System..::.String
The error message that explains the reason for the exception.
innerException
Type: System..::.Exception
The exception that is the cause of the current exception.

Exceptions

Exception | Condition
System..::.ArgumentNullException | The innerException argument is null.

See Also

AggregateException Class
AggregateException Overload
System Namespace


AggregateException Constructor (String, Exception[])

[image]

.NET Framework Class Library
AggregateException Constructor (String, array<Exception>[]()[])
AggregateException Class See Also Send Feedback

Initializes a new instance of the AggregateException class with a specified error message and references to the inner exceptions that are the cause of this exception.

Namespace: System
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Sub New ( _
    message As String, _
    ParamArray innerExceptions As Exception() _
)
C#
public AggregateException(
    string message,
    params Exception[] innerExceptions
)

Parameters

message
Type: System..::.String
The error message that explains the reason for the exception.
innerExceptions
Type: array< System..::.Exception >[]()[]
The exceptions that are the cause of the current exception.

Exceptions

Exception | Condition
System..::.ArgumentNullException | The innerExceptions argument is null.
System..::.ArgumentException | An element of innerExceptions is null.

See Also

AggregateException Class
AggregateException Overload
System Namespace


AggregateException Methods

[image] [image]

.NET Framework Class Library
AggregateException Methods
AggregateException Class See Also Send Feedback

The AggregateException type exposes the following members.

Methods

Name | Description
Equals | (Inherited from Object.)
Finalize | (Inherited from Object.)
Flatten | Flattens an AggregateException instances into a single, new instance.
GetBaseException | Returns the AggregateException that is the root cause of this exception. (Overrides Exception..::.GetBaseException()()().)
GetHashCode | (Inherited from Object.)
GetObjectData | Sets the SerializationInfo with information about the exception. (Overrides Exception..::.GetObjectData(SerializationInfo, StreamingContext).)
GetType | (Inherited from Exception.)
Handle | Invokes a handler on each Exception contained by this AggregateException.
MemberwiseClone | (Inherited from Object.)
ToString | Creates and returns a string representation of the current AggregateException. (Overrides Exception..::.ToString()()().)

See Also

AggregateException Class
System Namespace


Flatten Method

[image]

.NET Framework Class Library
AggregateException..::.Flatten Method
AggregateException Class See Also Send Feedback

Flattens an AggregateException instances into a single, new instance.

Namespace: System
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Function Flatten As AggregateException
C#
public AggregateException Flatten()

Return Value

A new, flattened AggregateException.

Remarks

If any inner exceptions are themselves instances of AggregateException, this method will recursively flatten all of them. The inner exceptions returned in the new AggregateException will be the union of all of the the inner exceptions from exception tree rooted at the provided AggregateException instance.

See Also

AggregateException Class
System Namespace


GetBaseException Method

[image]

.NET Framework Class Library
AggregateException..::.GetBaseException Method
AggregateException Class See Also Send Feedback

Returns the AggregateException that is the root cause of this exception.

Namespace: System
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Overrides Function GetBaseException As Exception
C#
public override Exception GetBaseException()

Implements

_Exception..::.GetBaseException()()()

See Also

AggregateException Class
System Namespace


GetObjectData Method

[image]

.NET Framework Class Library
AggregateException..::.GetObjectData Method
AggregateException Class See Also Send Feedback

Sets the SerializationInfo with information about the exception.

Namespace: System
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Overrides Sub GetObjectData ( _
    info As SerializationInfo, _
    context As StreamingContext _
)
C#
public override void GetObjectData(
    SerializationInfo info,
    StreamingContext context
)

Parameters

info
Type: System.Runtime.Serialization..::.SerializationInfo
The SerializationInfo that holds the serialized object data about the exception being thrown.
context
Type: System.Runtime.Serialization..::.StreamingContext
The StreamingContext that contains contextual information about the source or destination.

Implements

ISerializable..::.GetObjectData(SerializationInfo, StreamingContext)
_Exception..::.GetObjectData(SerializationInfo, StreamingContext)

Exceptions

Exception | Condition
System..::.ArgumentNullException | The info argument is null.

See Also

AggregateException Class
System Namespace


Handle Method

[image]

.NET Framework Class Library
AggregateException..::.Handle Method
AggregateException Class See Also Send Feedback

Invokes a handler on each Exception contained by this AggregateException.

Namespace: System
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Sub Handle ( _
    predicate As Func(Of Exception, Boolean) _
)
C#
public void Handle(
    Func<Exception, bool> predicate
)

Parameters

predicate
Type: System..::.Func<(Of <(Exception, Boolean>)>)
The predicate to execute for each exception. The predicate accepts as an argument the Exception to be processed and returns a Boolean to indicate whether the exception was handled.

Remarks

Each invocation of the predicate returns true or false to indicate whether the Exception was handled. After all invocations, if any exceptions went unhandled, all unhandled exceptions will be put into a new AggregateException which will be thrown. Otherwise, the Handle(Func<(Of <(Exception, Boolean>)>)) method simply returns. If any invocations of the predicate throws an exception, it will halt the processing of any more exceptions and immediately propagate the thrown exception as-is.

Exceptions

Exception | Condition
System..::.AggregateException | An exception contained by this AggregateException was not handled.
System..::.ArgumentNullException | The predicate argument is null.

See Also

AggregateException Class
System Namespace


ToString Method

[image]

.NET Framework Class Library
AggregateException..::.ToString Method
AggregateException Class See Also Send Feedback

Creates and returns a string representation of the current AggregateException.

Namespace: System
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Overrides Function ToString As String
C#
public override string ToString()

Return Value

A string representation of the current exception.

Implements

_Exception..::.ToString()()()

See Also

AggregateException Class
System Namespace


AggregateException Properties

[image] [image]

.NET Framework Class Library
AggregateException Properties
AggregateException Class See Also Send Feedback

The AggregateException type exposes the following members.

Properties

Name | Description
Data | (Inherited from Exception.)
HelpLink | (Inherited from Exception.)
HResult | (Inherited from Exception.)
InnerException | (Inherited from Exception.)
InnerExceptions | Gets a read-only collection of the Exception instances that caused the current exception.
Message | (Inherited from Exception.)
Source | (Inherited from Exception.)
StackTrace | (Inherited from Exception.)
TargetSite | (Inherited from Exception.)

See Also

AggregateException Class
System Namespace


InnerExceptions Property

[image]

.NET Framework Class Library
AggregateException..::.InnerExceptions Property
AggregateException Class See Also Send Feedback

Gets a read-only collection of the Exception instances that caused the current exception.

Namespace: System
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public ReadOnly Property InnerExceptions As ReadOnlyCollection(Of Exception)
C#
public ReadOnlyCollection<Exception> InnerExceptions { get; }

See Also

AggregateException Class
System Namespace


Func_(T1, T2, T3, T4, T5, TResult) Delegate

[image]

.NET Framework Class Library
Func_<(Of <(T1, T2, T3, T4, T5, TResult>)>) Delegate
See Also Send Feedback

Encapsulates a method that has five parameters and returns a value of the type specified by the TResult parameter.

Namespace: System
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Delegate Function Func_(Of T1, T2, T3, T4, T5, TResult) ( _
    arg1 As T1, _
    arg2 As T2, _
    arg3 As T3, _
    arg4 As T4, _
    arg5 As T5 _
) As TResult
C#
public delegate TResult Func_<T1, T2, T3, T4, T5, TResult>(
    T1 arg1,
    T2 arg2,
    T3 arg3,
    T4 arg4,
    T5 arg5
)

Parameters

arg1
Type: T1
arg2
Type: T2
arg3
Type: T3
arg4
Type: T4
arg5
Type: T5

Type Parameters

T1
T2
T3
T4
T5
TResult

See Also

System Namespace


Lazy(T) Class

[image]

.NET Framework Class Library
Lazy<(Of <(T>)>) Class
See Also Send Feedback

Provides support for lazy initialization.

Namespace: System
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
<SerializableAttribute> _
<ComVisibleAttribute(False)> _
<HostProtectionAttribute(SecurityAction.LinkDemand, Synchronization := True,  _
    ExternalThreading := True)> _
Public Class Lazy(Of T)
C#
[SerializableAttribute]
[ComVisibleAttribute(false)]
[HostProtectionAttribute(SecurityAction.LinkDemand, Synchronization = true,
    ExternalThreading = true)]
public class Lazy<T>

Type Parameters

T
Specifies the type of element being laziliy initialized.

Remarks

By default, all public and protected members of Lazy<(Of <(T>)>) are thread-safe and may be used concurrently from multiple threads. These thread-safety guarantees may be removed optionally and per instance using parameters to the type's constructors.

Inheritance Hierarchy

System..::.Object
System..::.Lazy<(Of <(T>)>)

See Also

System Namespace


Lazy(T) Constructor

[image] [image]

.NET Framework Class Library
Lazy<(Of <(T>)>) Constructor
Lazy<(Of <(T>)>) Class See Also Send Feedback

Overload List

Name | Description
Lazy<(Of <(T>)>)()()() | Initializes a new instance of the Lazy<(Of <(T>)>) class that uses T's default constructor for lazy initialization.
Lazy<(Of <(T>)>)(Boolean) | Initializes a new instance of the Lazy<(Of <(T>)>) class that uses T's default constructor and a specified thread-safety mode.
Lazy<(Of <(T>)>)(Func<(Of <(T>)>)) | Initializes a new instance of the Lazy<(Of <(T>)>) class that uses a specified initialization function.
Lazy<(Of <(T>)>)(LazyThreadSafetyMode) | Initializes a new instance of the Lazy<(Of <(T>)>) class that uses T's default constructor and a specified thread-safety mode.
Lazy<(Of <(T>)>)(Func<(Of <(T>)>), Boolean) | Initializes a new instance of the Lazy<(Of <(T>)>) class that uses a specified initialization function and a specified thread-safety mode.
Lazy<(Of <(T>)>)(Func<(Of <(T>)>), LazyThreadSafetyMode) | Initializes a new instance of the Lazy<(Of <(T>)>) class that uses a specified initialization function and a specified thread-safety mode.

See Also

Lazy<(Of <(T>)>) Class
System Namespace


Lazy(T) Constructor

[image]

.NET Framework Class Library
Lazy<(Of <(T>)>) Constructor
Lazy<(Of <(T>)>) Class See Also Send Feedback

Initializes a new instance of the Lazy<(Of <(T>)>) class that uses T's default constructor for lazy initialization.

Namespace: System
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Sub New
C#
public Lazy()

Remarks

An instance created with this constructor may be used concurrently from multiple threads.

See Also

Lazy<(Of <(T>)>) Class
Lazy<(Of <(T>)>) Overload
System Namespace


Lazy(T) Constructor (Boolean)

[image]

.NET Framework Class Library
Lazy<(Of <(T>)>) Constructor (Boolean)
Lazy<(Of <(T>)>) Class See Also Send Feedback

Initializes a new instance of the Lazy<(Of <(T>)>) class that uses T's default constructor and a specified thread-safety mode.

Namespace: System
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Sub New ( _
    isThreadSafe As Boolean _
)
C#
public Lazy(
    bool isThreadSafe
)

Parameters

isThreadSafe
Type: System..::.Boolean
true if this instance should be usable by multiple threads concurrently; false if the instance will only be used by one thread at a time.

See Also

Lazy<(Of <(T>)>) Class
Lazy<(Of <(T>)>) Overload
System Namespace


Lazy(T) Constructor (Func(T))

[image]

.NET Framework Class Library
Lazy<(Of <(T>)>) Constructor (Func<(Of <(T>)>))
Lazy<(Of <(T>)>) Class See Also Send Feedback

Initializes a new instance of the Lazy<(Of <(T>)>) class that uses a specified initialization function.

Namespace: System
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Sub New ( _
    valueFactory As Func(Of T) _
)
C#
public Lazy(
    Func<T> valueFactory
)

Parameters

valueFactory
Type: System..::.Func<(Of <( T >)>)
The Func<(Of <(T>)>) invoked to produce the lazily-initialized value when it is needed.

Remarks

An instance created with this constructor may be used concurrently from multiple threads.

Exceptions

Exception | Condition
System..::.ArgumentNullException | valueFactory is a null reference (Nothing in Visual Basic).

See Also

Lazy<(Of <(T>)>) Class
Lazy<(Of <(T>)>) Overload
System Namespace


Lazy(T) Constructor (LazyThreadSafetyMode)

[image]

.NET Framework Class Library
Lazy<(Of <(T>)>) Constructor (LazyThreadSafetyMode)
Lazy<(Of <(T>)>) Class See Also Send Feedback

Initializes a new instance of the Lazy<(Of <(T>)>) class that uses T's default constructor and a specified thread-safety mode.

Namespace: System
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Sub New ( _
    mode As LazyThreadSafetyMode _
)
C#
public Lazy(
    LazyThreadSafetyMode mode
)

Parameters

mode
Type: System.Threading..::.LazyThreadSafetyMode
The lazy thread-safety mode mode

Exceptions

Exception | Condition
System..::.ArgumentOutOfRangeException | mode mode contains an invalid valuee

See Also

Lazy<(Of <(T>)>) Class
Lazy<(Of <(T>)>) Overload
System Namespace


Lazy(T) Constructor (Func(T), Boolean)

[image]

.NET Framework Class Library
Lazy<(Of <(T>)>) Constructor (Func<(Of <(T>)>), Boolean)
Lazy<(Of <(T>)>) Class See Also Send Feedback

Initializes a new instance of the Lazy<(Of <(T>)>) class that uses a specified initialization function and a specified thread-safety mode.

Namespace: System
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Sub New ( _
    valueFactory As Func(Of T), _
    isThreadSafe As Boolean _
)
C#
public Lazy(
    Func<T> valueFactory,
    bool isThreadSafe
)

Parameters

valueFactory
Type: System..::.Func<(Of <( T >)>)
The Func<(Of <(T>)>) invoked to produce the lazily-initialized value when it is needed.
isThreadSafe
Type: System..::.Boolean
true if this instance should be usable by multiple threads concurrently; false if the instance will only be used by one thread at a time.

Exceptions

Exception | Condition
System..::.ArgumentNullException | valueFactory is a null reference (Nothing in Visual Basic).

See Also

Lazy<(Of <(T>)>) Class
Lazy<(Of <(T>)>) Overload
System Namespace


Lazy(T) Constructor (Func(T), LazyThreadSafetyMode)

[image]

.NET Framework Class Library
Lazy<(Of <(T>)>) Constructor (Func<(Of <(T>)>), LazyThreadSafetyMode)
Lazy<(Of <(T>)>) Class See Also Send Feedback

Initializes a new instance of the Lazy<(Of <(T>)>) class that uses a specified initialization function and a specified thread-safety mode.

Namespace: System
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Sub New ( _
    valueFactory As Func(Of T), _
    mode As LazyThreadSafetyMode _
)
C#
public Lazy(
    Func<T> valueFactory,
    LazyThreadSafetyMode mode
)

Parameters

valueFactory
Type: System..::.Func<(Of <( T >)>)
The Func<(Of <(T>)>) invoked to produce the lazily-initialized value when it is needed.
mode
Type: System.Threading..::.LazyThreadSafetyMode
The lazy thread-safety mode.

Exceptions

Exception | Condition
System..::.ArgumentNullException | valueFactory is a null reference (Nothing in Visual Basic).
System..::.ArgumentOutOfRangeException | mode mode contains an invalid value.

See Also

Lazy<(Of <(T>)>) Class
Lazy<(Of <(T>)>) Overload
System Namespace


Lazy(T) Methods

[image] [image]

.NET Framework Class Library
Lazy<(Of <(T>)>) Methods
Lazy<(Of <(T>)>) Class See Also Send Feedback

The Lazy<(Of <(T>)>) type exposes the following members.

Methods

Name | Description
Equals | (Inherited from Object.)
Finalize | (Inherited from Object.)
GetHashCode | (Inherited from Object.)
GetType | (Inherited from Object.)
MemberwiseClone | (Inherited from Object.)
ToString | Creates and returns a string representation of this instance. (Overrides Object..::.ToString()()().)

See Also

Lazy<(Of <(T>)>) Class
System Namespace


ToString Method

[image]

.NET Framework Class Library
Lazy<(Of <(T>)>)..::.ToString Method
Lazy<(Of <(T>)>) Class See Also Send Feedback

Creates and returns a string representation of this instance.

Namespace: System
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Overrides Function ToString As String
C#
public override string ToString()

Return Value

The result of calling ToString()()() on the Value.

Exceptions

Exception | Condition
System..::.NullReferenceException | The Value is null.

See Also

Lazy<(Of <(T>)>) Class
System Namespace


Lazy(T) Properties

[image] [image]

.NET Framework Class Library
Lazy<(Of <(T>)>) Properties
Lazy<(Of <(T>)>) Class See Also Send Feedback

The Lazy<(Of <(T>)>) type exposes the following members.

Properties

Name | Description
IsValueCreated | Gets a value indicating whether the Lazy<(Of <(T>)>) has been initialized.
Value |

See Also

Lazy<(Of <(T>)>) Class
System Namespace


IsValueCreated Property

[image]

.NET Framework Class Library
Lazy<(Of <(T>)>)..::.IsValueCreated Property
Lazy<(Of <(T>)>) Class See Also Send Feedback

Gets a value indicating whether the Lazy<(Of <(T>)>) has been initialized.

Namespace: System
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public ReadOnly Property IsValueCreated As Boolean
C#
public bool IsValueCreated { get; }

Field Value

true if the Lazy<(Of <(T>)>) instance has been initialized; otherwise, false.

Remarks

The initialization of a Lazy<(Of <(T>)>) instance may result in either a value being produced or an exception being thrown. If an exception goes unhandled during initialization, IsValueCreated will return false.

See Also

Lazy<(Of <(T>)>) Class
System Namespace


Value Property

[image]

.NET Framework Class Library
Lazy<(Of <(T>)>)..::.Value Property
Lazy<(Of <(T>)>) Class See Also Send Feedback

Namespace: System
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public ReadOnly Property Value As T
C#
public T Value { get; }

See Also

Lazy<(Of <(T>)>) Class
System Namespace


System.Collections.Concurrent Namespace

[image]

.NET Framework Class Library
System.Collections.Concurrent Namespace
Send Feedback

Classes

Class | Description
BlockingCollection<(Of <(T>)>) | Provides blocking and bounding capabilities for thread-safe collections that implement IProducerConsumerCollection<(Of <(T>)>).
ConcurrentBag<(Of <(T>)>) | Represents an thread-safe, unordered collection of objects.
ConcurrentDictionary<(Of <(TKey, TValue>)>) | Represents a thread-safe collection of keys and values.
ConcurrentQueue<(Of <(T>)>) | Represents a thread-safe first-in, first-out collection of objects.
ConcurrentStack<(Of <(T>)>) | Represents a thread-safe last-in, first-out collection of objects.
OrderablePartitioner<(Of <(TSource>)>) | Represents a particular manner of splitting an orderable data source into multiple partitions.
Partitioner | Provides common partitioning strategies for arrays, lists, and enumerables.
Partitioner<(Of <(TSource>)>) | Represents a particular manner of splitting a data source into multiple partitions.

Interfaces

Interface | Description
IProducerConsumerCollection<(Of <(T>)>) | Defines methods to manipulate thread-safe collections intended for producer/consumer usage.


BlockingCollection(T) Class

[image]

.NET Framework Class Library
BlockingCollection<(Of <(T>)>) Class
See Also Send Feedback

Provides blocking and bounding capabilities for thread-safe collections that implement IProducerConsumerCollection<(Of <(T>)>).

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

Syntax

Visual Basic (Declaration)
<ComVisibleAttribute(False)> _
<HostProtectionAttribute(SecurityAction.LinkDemand, Synchronization := True,  _
    ExternalThreading := True)> _
Public Class BlockingCollection(Of T) _
    Implements IEnumerable(Of T), ICollection, IEnumerable,  _
    IDisposable
C#
[ComVisibleAttribute(false)]
[HostProtectionAttribute(SecurityAction.LinkDemand, Synchronization = true,
    ExternalThreading = true)]
public class BlockingCollection<T> : IEnumerable<T>,
    ICollection, IEnumerable, IDisposable

Type Parameters

T
Specifies the type of elements in the collection.

Remarks

IProducerConsumerCollection<(Of <(T>)>) represents a collection that allows for thread-safe adding and removing of data. BlockingCollection<(Of <(T>)>) is used as a wrapper for an IProducerConsumerCollection<(Of <(T>)>) instance, allowing removal attempts from the collection to block until data is available to be removed. Similarly, a BlockingCollection<(Of <(T>)>) can be created to enforce an upper-bound on the number of data elements allowed in the IProducerConsumerCollection<(Of <(T>)>); addition attempts to the collection may then block until space is available to store the added items. In this manner, BlockingCollection<(Of <(T>)>) is similar to a traditional blocking queue data structure, except that the underlying data storage mechanism is abstracted away as an IProducerConsumerCollection<(Of <(T>)>).

Inheritance Hierarchy

System..::.Object
System.Collections.Concurrent..::.BlockingCollection<(Of <(T>)>)

See Also

System.Collections.Concurrent Namespace


BlockingCollection(T) Constructor

[image] [image]

.NET Framework Class Library
BlockingCollection<(Of <(T>)>) Constructor
BlockingCollection<(Of <(T>)>) Class See Also Send Feedback

Overload List

Name | Description
BlockingCollection<(Of <(T>)>)()()() | Initializes a new instance of the BlockingCollection<(Of <(T>)>) class without an upper-bound.
BlockingCollection<(Of <(T>)>)(IProducerConsumerCollection<(Of <(T>)>)) | Initializes a new instance of the BlockingCollection<(Of <(T>)>) class without an upper-bound and using the provided IProducerConsumerCollection<(Of <(T>)>) as its underlying data store.
BlockingCollection<(Of <(T>)>)(Int32) | Initializes a new instance of the BlockingCollection<(Of <(T>)>) class with the specified upper-bound.
BlockingCollection<(Of <(T>)>)(IProducerConsumerCollection<(Of <(T>)>), Int32) | Initializes a new instance of the BlockingCollection<(Of <(T>)>) class with the specified upper-bound and using the provided IProducerConsumerCollection<(Of <(T>)>) as its underlying data store.

See Also

BlockingCollection<(Of <(T>)>) Class
System.Collections.Concurrent Namespace


BlockingCollection(T) Constructor

[image]

.NET Framework Class Library
BlockingCollection<(Of <(T>)>) Constructor
BlockingCollection<(Of <(T>)>) Class See Also Send Feedback

Initializes a new instance of the BlockingCollection<(Of <(T>)>) class without an upper-bound.

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

Syntax

Visual Basic (Declaration)
Public Sub New
C#
public BlockingCollection()

Remarks

The default underlying collection is a ConcurrentQueue<T>.

See Also

BlockingCollection<(Of <(T>)>) Class
BlockingCollection<(Of <(T>)>) Overload
System.Collections.Concurrent Namespace


BlockingCollection(T) Constructor (IProducerConsumerCollection(T))

[image]

.NET Framework Class Library
BlockingCollection<(Of <(T>)>) Constructor (IProducerConsumerCollection<(Of <(T>)>))
BlockingCollection<(Of <(T>)>) Class See Also Send Feedback

Initializes a new instance of the BlockingCollection<(Of <(T>)>) class without an upper-bound and using the provided IProducerConsumerCollection<(Of <(T>)>) as its underlying data store.

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

Syntax

Visual Basic (Declaration)
Public Sub New ( _
    collection As IProducerConsumerCollection(Of T) _
)
C#
public BlockingCollection(
    IProducerConsumerCollection<T> collection
)

Parameters

collection
Type: System.Collections.Concurrent..::.IProducerConsumerCollection <(Of <( T >)>)
The collection to use as the underlying data store.

Exceptions

Exception | Condition
System..::.ArgumentNullException | The collection argument is null.

See Also

BlockingCollection<(Of <(T>)>) Class
BlockingCollection<(Of <(T>)>) Overload
System.Collections.Concurrent Namespace


BlockingCollection(T) Constructor (Int32)

[image]

.NET Framework Class Library
BlockingCollection<(Of <(T>)>) Constructor (Int32)
BlockingCollection<(Of <(T>)>) Class See Also Send Feedback

Initializes a new instance of the BlockingCollection<(Of <(T>)>) class with the specified upper-bound.

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

Syntax

Visual Basic (Declaration)
Public Sub New ( _
    boundedCapacity As Integer _
)
C#
public BlockingCollection(
    int boundedCapacity
)

Parameters

boundedCapacity
Type: System..::.Int32
The bounded size of the collection.

Remarks

The default underlying collection is a ConcurrentQueue<T>.

Exceptions

Exception | Condition
System..::.ArgumentOutOfRangeException | The boundedCapacity is not a positive value.

See Also

BlockingCollection<(Of <(T>)>) Class
BlockingCollection<(Of <(T>)>) Overload
System.Collections.Concurrent Namespace


BlockingCollection(T) Constructor (IProducerConsumerCollection(T), Int32)

[image]

.NET Framework Class Library
BlockingCollection<(Of <(T>)>) Constructor (IProducerConsumerCollection<(Of <(T>)>), Int32)
BlockingCollection<(Of <(T>)>) Class See Also Send Feedback

Initializes a new instance of the BlockingCollection<(Of <(T>)>) class with the specified upper-bound and using the provided IProducerConsumerCollection<(Of <(T>)>) as its underlying data store.

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

Syntax

Visual Basic (Declaration)
Public Sub New ( _
    collection As IProducerConsumerCollection(Of T), _
    boundedCapacity As Integer _
)
C#
public BlockingCollection(
    IProducerConsumerCollection<T> collection,
    int boundedCapacity
)

Parameters

collection
Type: System.Collections.Concurrent..::.IProducerConsumerCollection <(Of <( T >)>)
The collection to use as the underlying data store.
boundedCapacity
Type: System..::.Int32
The bounded size of the collection.

Exceptions

Exception | Condition
System..::.ArgumentNullException | The collection argument is null.
System..::.ArgumentOutOfRangeException | The boundedCapacity is not a positive value.
System..::.ArgumentException | The supplied collection contains more values than is permitted by boundedCapacity.

See Also

BlockingCollection<(Of <(T>)>) Class
BlockingCollection<(Of <(T>)>) Overload
System.Collections.Concurrent Namespace


BlockingCollection(T) Methods

[image] [image]

.NET Framework Class Library
BlockingCollection<(Of <(T>)>) Methods
BlockingCollection<(Of <(T>)>) Class See Also Send Feedback

The BlockingCollection<(Of <(T>)>) type exposes the following members.

Methods

Name | Description
Add | Overloaded.
AddToAny | Overloaded.
CompleteAdding | Marks the BlockingCollection<(Of <(T>)>) instances as not accepting any more additions.
CopyTo | Copies all of the items in the BlockingCollection<(Of <(T>)>) instance to a compatible one-dimensional array, starting at the specified index of the target array.
Dispose | Overloaded.
Equals | (Inherited from Object.)
Finalize | (Inherited from Object.)
GetConsumingEnumerable | Overloaded.
GetHashCode | (Inherited from Object.)
GetType | (Inherited from Object.)
MemberwiseClone | (Inherited from Object.)
Take | Overloaded.
TakeFromAny | Overloaded.
ToArray | Copies the items from the BlockingCollection<(Of <(T>)>) instance into a new array.
ToString | (Inherited from Object.)
TryAdd | Overloaded.
TryAddToAny | Overloaded.
TryTake | Overloaded.
TryTakeFromAny | Overloaded.

Explicit Interface Implementations

Name | Description
ICollection..::.CopyTo | Copies all of the items in the BlockingCollection<(Of <(T>)>) instance to a compatible one-dimensional array, starting at the specified index of the target array.
IEnumerable<(Of <(T>)>)..::.GetEnumerator | Provides an IEnumerator<(Of <(T>)>) for items in the collection.
IEnumerable..::.GetEnumerator | Provides an IEnumerator for items in the collection.

See Also

BlockingCollection<(Of <(T>)>) Class
System.Collections.Concurrent Namespace


ICollection.CopyTo Method

[image]

.NET Framework Class Library
BlockingCollection<(Of <(T>)>)..::.ICollection..::.CopyTo Method
BlockingCollection<(Of <(T>)>) Class See Also Send Feedback

Copies all of the items in the BlockingCollection<(Of <(T>)>) instance to a compatible one-dimensional array, starting at the specified index of the target array.

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

Syntax

Visual Basic (Declaration)
Private Sub CopyTo ( _
    array As Array, _
    index As Integer _
) Implements ICollection.CopyTo
C#
void ICollection.CopyTo(
    Array array,
    int index
)

Parameters

array
Type: System..::.Array
The one-dimensional array that is the destination of the elements copied from the BlockingCollection<(Of <(T>)>) instance. The array must have zero-based indexing.
index
Type: System..::.Int32
The zero-based index in array at which copying begins.

Implements

ICollection..::.CopyTo(Array, Int32)

Exceptions

Exception | Condition
System..::.ArgumentNullException | The array argument is null.
System..::.ArgumentOutOfRangeException | The index argument is less than zero.
System..::.ArgumentException | The index argument is equal to or greater than the length of the array, the array is multidimensional, or the type parameter for the collection cannot be cast automatically to the type of the destination array.
System..::.ObjectDisposedException | The BlockingCollection<(Of <(T>)>) has been disposed.

See Also

BlockingCollection<(Of <(T>)>) Class
System.Collections.Concurrent Namespace


IEnumerable(T).GetEnumerator Method

[image]

.NET Framework Class Library
BlockingCollection<(Of <(T>)>)..::.IEnumerable<(Of <(T>)>)..::.GetEnumerator Method
BlockingCollection<(Of <(T>)>) Class See Also Send Feedback

Provides an IEnumerator<(Of <(T>)>) for items in the collection.

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

Syntax

Visual Basic (Declaration)
Private Function GetEnumerator As IEnumerator(Of T)
    Implements IEnumerable(Of T).GetEnumerator
C#
IEnumerator<T> IEnumerable<T>.GetEnumerator()

Return Value

An IEnumerator<(Of <(T>)>) for the items in the collection.

Implements

IEnumerable<(Of <(T>)>)..::.GetEnumerator()()()

Exceptions

Exception | Condition
System..::.ObjectDisposedException | The BlockingCollection<(Of <(T>)>) has been disposed.

See Also

BlockingCollection<(Of <(T>)>) Class
System.Collections.Concurrent Namespace


IEnumerable.GetEnumerator Method

[image]

.NET Framework Class Library
BlockingCollection<(Of <(T>)>)..::.IEnumerable..::.GetEnumerator Method
BlockingCollection<(Of <(T>)>) Class See Also Send Feedback

Provides an IEnumerator for items in the collection.

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

Syntax

Visual Basic (Declaration)
Private Function GetEnumerator As IEnumerator
    Implements IEnumerable.GetEnumerator
C#
IEnumerator IEnumerable.GetEnumerator()

Return Value

An IEnumerator for the items in the collection.

Implements

IEnumerable..::.GetEnumerator()()()

Exceptions

Exception | Condition
System..::.ObjectDisposedException | The BlockingCollection<(Of <(T>)>) has been disposed.

See Also

BlockingCollection<(Of <(T>)>) Class
System.Collections.Concurrent Namespace


Add Method

[image] [image]

.NET Framework Class Library
BlockingCollection<(Of <(T>)>)..::.Add Method
BlockingCollection<(Of <(T>)>) Class See Also Send Feedback

Overload List

Name | Description
Add(T) | Adds the item to the BlockingCollection<(Of <(T>)>).
Add(T, CancellationToken) | Adds the item to the BlockingCollection<(Of <(T>)>). A OperationCanceledException is thrown if the CancellationToken is canceled.

See Also

BlockingCollection<(Of <(T>)>) Class
System.Collections.Concurrent Namespace


Add Method (T)

[image]

.NET Framework Class Library
BlockingCollection<(Of <(T>)>)..::.Add Method (T)
BlockingCollection<(Of <(T>)>) Class See Also Send Feedback

Adds the item to the BlockingCollection<(Of <(T>)>).

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

Syntax

Visual Basic (Declaration)
Public Sub Add ( _
    item As T _
)
C#
public void Add(
    T item
)

Parameters

item
Type: T
The item to be added to the collection. The value can be a null reference.

Remarks

If a bounded capacity was specified when this instance of BlockingCollection<(Of <(T>)>) was initialized, a call to Add may block until space is available to store the provided item.

Exceptions

Exception | Condition
System..::.InvalidOperationException | The BlockingCollection<(Of <(T>)>) has been marked as complete with regards to additions.
System..::.ObjectDisposedException | The BlockingCollection<(Of <(T>)>) has been disposed.
System..::.InvalidOperationException | The underlying collection didn't accept the item.

See Also

BlockingCollection<(Of <(T>)>) Class
Add Overload
System.Collections.Concurrent Namespace


Add Method (T, CancellationToken)

[image]

.NET Framework Class Library
BlockingCollection<(Of <(T>)>)..::.Add Method (T, CancellationToken)
BlockingCollection<(Of <(T>)>) Class See Also Send Feedback

Adds the item to the BlockingCollection<(Of <(T>)>). A OperationCanceledException is thrown if the CancellationToken is canceled.

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

Syntax

Visual Basic (Declaration)
Public Sub Add ( _
    item As T, _
    cancellationToken As CancellationToken _
)
C#
public void Add(
    T item,
    CancellationToken cancellationToken
)

Parameters

item
Type: T
The item to be added to the collection. The value can be a null reference.
cancellationToken
Type: System.Threading..::.CancellationToken
A cancellation token to observe.

Remarks

If a bounded capacity was specified when this instance of BlockingCollection<(Of <(T>)>) was initialized, a call to Add(T, CancellationToken) may block until space is available to store the provided item.

Exceptions

Exception | Condition
System..::.OperationCanceledException | If the CancellationToken is canceled.
System..::.InvalidOperationException | The BlockingCollection<(Of <(T>)>) has been marked as complete with regards to additions.
System..::.ObjectDisposedException | The BlockingCollection<(Of <(T>)>) has been disposed.
System..::.InvalidOperationException | The underlying collection didn't accept the item.

See Also

BlockingCollection<(Of <(T>)>) Class
Add Overload
System.Collections.Concurrent Namespace


AddToAny Method

[image] [image]

.NET Framework Class Library
BlockingCollection<(Of <(T>)>)..::.AddToAny Method
BlockingCollection<(Of <(T>)>) Class See Also Send Feedback

Overload List

Name | Description
AddToAny(array<BlockingCollection<(Of <(T>)>)>[]()[], T) | Adds the specified item to any one of the specified BlockingCollection<(Of <(T>)>) instances.
AddToAny(array<BlockingCollection<(Of <(T>)>)>[]()[], T, CancellationToken) | Adds the specified item to any one of the specified BlockingCollection<(Of <(T>)>) instances. A OperationCanceledException is thrown if the CancellationToken is canceled.

See Also

BlockingCollection<(Of <(T>)>) Class
System.Collections.Concurrent Namespace


AddToAny Method (BlockingCollection(T)[], T)

[image]

.NET Framework Class Library
BlockingCollection<(Of <(T>)>)..::.AddToAny Method (array<BlockingCollection<(Of <(T>)>)>[]()[], T)
BlockingCollection<(Of <(T>)>) Class See Also Send Feedback

Adds the specified item to any one of the specified BlockingCollection<(Of <(T>)>) instances.

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

Syntax

Visual Basic (Declaration)
Public Shared Function AddToAny ( _
    collections As BlockingCollection(Of T)(), _
    item As T _
) As Integer
C#
public static int AddToAny(
    BlockingCollection<T>[] collections,
    T item
)

Parameters

collections
Type: array< System.Collections.Concurrent..::.BlockingCollection <(Of <( T >)>) >[]()[]
The array of collections.
item
Type: T
The item to be added to one of the collections.

Return Value

The index of the collection in the collections array to which the item was added.

Remarks

If a bounded capacity was specified when all of the BlockingCollection<(Of <(T>)>) instances were initialized, a call to AddToAny may block until space is available in one of the collections to store the provided item.

Exceptions

Exception | Condition
System..::.ArgumentNullException | The collections argument is null.
System..::.ArgumentException | The collections argument is a 0-length array or contains a null element, or at least one of collections has been marked as complete for adding.
System..::.ObjectDisposedException | At least one of the BlockingCollection<(Of <(T>)>) instances has been disposed.
System..::.InvalidOperationException | At least one underlying collection didn't accept the item.
System..::.ArgumentOutOfRangeException | The count of collections is greater than the maximum size of 62 for STA and 63 for MTA.

See Also

BlockingCollection<(Of <(T>)>) Class
AddToAny Overload
System.Collections.Concurrent Namespace


AddToAny Method (BlockingCollection(T)[], T, CancellationToken)

[image]

.NET Framework Class Library
BlockingCollection<(Of <(T>)>)..::.AddToAny Method (array<BlockingCollection<(Of <(T>)>)>[]()[], T, CancellationToken)
BlockingCollection<(Of <(T>)>) Class See Also Send Feedback

Adds the specified item to any one of the specified BlockingCollection<(Of <(T>)>) instances. A OperationCanceledException is thrown if the CancellationToken is canceled.

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

Syntax

Visual Basic (Declaration)
Public Shared Function AddToAny ( _
    collections As BlockingCollection(Of T)(), _
    item As T, _
    cancellationToken As CancellationToken _
) As Integer
C#
public static int AddToAny(
    BlockingCollection<T>[] collections,
    T item,
    CancellationToken cancellationToken
)

Parameters

collections
Type: array< System.Collections.Concurrent..::.BlockingCollection <(Of <( T >)>) >[]()[]
The array of collections.
item
Type: T
The item to be added to one of the collections.
cancellationToken
Type: System.Threading..::.CancellationToken
A cancellation token to observe.

Return Value

The index of the collection in the collections array to which the item was added.

Remarks

If a bounded capacity was specified when all of the BlockingCollection<(Of <(T>)>) instances were initialized, a call to AddToAny may block until space is available in one of the collections to store the provided item.

Exceptions

Exception | Condition
System..::.OperationCanceledException | If the CancellationToken is canceled.
System..::.ArgumentNullException | The collections argument is null.
System..::.ArgumentException | The collections argument is a 0-length array or contains a null element, or at least one of collections has been marked as complete for adding.
System..::.ObjectDisposedException | At least one of the BlockingCollection<(Of <(T>)>) instances has been disposed.
System..::.InvalidOperationException | At least one underlying collection didn't accept the item.
System..::.ArgumentOutOfRangeException | The count of collections is greater than the maximum size of 62 for STA and 63 for MTA.

See Also

BlockingCollection<(Of <(T>)>) Class
AddToAny Overload
System.Collections.Concurrent Namespace


CompleteAdding Method

[image]

.NET Framework Class Library
BlockingCollection<(Of <(T>)>)..::.CompleteAdding Method
BlockingCollection<(Of <(T>)>) Class See Also Send Feedback

Marks the BlockingCollection<(Of <(T>)>) instances as not accepting any more additions.

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

Syntax

Visual Basic (Declaration)
Public Sub CompleteAdding
C#
public void CompleteAdding()

Remarks

After a collection has been marked as complete for adding, adding to the collection is not permitted and attempts to remove from the collection will not wait when the collection is empty.

Exceptions

Exception | Condition
System..::.ObjectDisposedException | The BlockingCollection<(Of <(T>)>) has been disposed.

See Also

BlockingCollection<(Of <(T>)>) Class
System.Collections.Concurrent Namespace


CopyTo Method

[image]

.NET Framework Class Library
BlockingCollection<(Of <(T>)>)..::.CopyTo Method
BlockingCollection<(Of <(T>)>) Class See Also Send Feedback

Copies all of the items in the BlockingCollection<(Of <(T>)>) instance to a compatible one-dimensional array, starting at the specified index of the target array.

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

Syntax

Visual Basic (Declaration)
Public Sub CopyTo ( _
    array As T(), _
    index As Integer _
)
C#
public void CopyTo(
    T[] array,
    int index
)

Parameters

array
Type: array< T >[]()[]
The one-dimensional array that is the destination of the elements copied from the BlockingCollection<(Of <(T>)>) instance. The array must have zero-based indexing.
index
Type: System..::.Int32
The zero-based index in array at which copying begins.

Exceptions

Exception | Condition
System..::.ArgumentNullException | The array argument is null.
System..::.ArgumentOutOfRangeException | The index argument is less than zero.
System..::.ArgumentException | The index argument is equal to or greater than the length of the array.
System..::.ObjectDisposedException | The BlockingCollection<(Of <(T>)>) has been disposed.

See Also

BlockingCollection<(Of <(T>)>) Class
System.Collections.Concurrent Namespace


Dispose Method

[image] [image]

.NET Framework Class Library
BlockingCollection<(Of <(T>)>)..::.Dispose Method
BlockingCollection<(Of <(T>)>) Class See Also Send Feedback

Overload List

Name | Description
Dispose()()() | Releases resources used by the BlockingCollection<(Of <(T>)>) instance.
Dispose(Boolean) | Releases resources used by the BlockingCollection<(Of <(T>)>) instance.

See Also

BlockingCollection<(Of <(T>)>) Class
System.Collections.Concurrent Namespace


Dispose Method

[image]

.NET Framework Class Library
BlockingCollection<(Of <(T>)>)..::.Dispose Method
BlockingCollection<(Of <(T>)>) Class See Also Send Feedback

Releases resources used by the BlockingCollection<(Of <(T>)>) instance.

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

Syntax

Visual Basic (Declaration)
Public Sub Dispose
C#
public void Dispose()

Implements

IDisposable..::.Dispose()()()

See Also

BlockingCollection<(Of <(T>)>) Class
Dispose Overload
System.Collections.Concurrent Namespace


Dispose Method (Boolean)

[image]

.NET Framework Class Library
BlockingCollection<(Of <(T>)>)..::.Dispose Method (Boolean)
BlockingCollection<(Of <(T>)>) Class See Also Send Feedback

Releases resources used by the BlockingCollection<(Of <(T>)>) instance.

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

Syntax

Visual Basic (Declaration)
Protected Overridable Sub Dispose ( _
    disposing As Boolean _
)
C#
protected virtual void Dispose(
    bool disposing
)

Parameters

disposing
Type: System..::.Boolean
Whether being disposed explicitly (true) or due to a finalizer (false).

See Also

BlockingCollection<(Of <(T>)>) Class
Dispose Overload
System.Collections.Concurrent Namespace


GetConsumingEnumerable Method

[image] [image]

.NET Framework Class Library
BlockingCollection<(Of <(T>)>)..::.GetConsumingEnumerable Method
BlockingCollection<(Of <(T>)>) Class See Also Send Feedback

Overload List

Name | Description
GetConsumingEnumerable()()() | Provides a consuming IEnumerable<(Of <(T>)>) for items in the collection.
GetConsumingEnumerable(CancellationToken) | Provides a consuming IEnumerable<(Of <(T>)>) for items in the collection. Calling MoveNext on the returned enumerable will block if there is no data available, or will throw an OperationCanceledException if the CancellationToken is canceled.

See Also

BlockingCollection<(Of <(T>)>) Class
System.Collections.Concurrent Namespace


GetConsumingEnumerable Method

[image]

.NET Framework Class Library
BlockingCollection<(Of <(T>)>)..::.GetConsumingEnumerable Method
BlockingCollection<(Of <(T>)>) Class See Also Send Feedback

Provides a consuming IEnumerable<(Of <(T>)>) for items in the collection.

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

Syntax

Visual Basic (Declaration)
Public Function GetConsumingEnumerable As IEnumerable(Of T)
C#
public IEnumerable<T> GetConsumingEnumerable()

Return Value

An IEnumerable<(Of <(T>)>) that removes and returns items from the collection.

Exceptions

Exception | Condition
System..::.ObjectDisposedException | The BlockingCollection<(Of <(T>)>) has been disposed.

See Also

BlockingCollection<(Of <(T>)>) Class
GetConsumingEnumerable Overload
System.Collections.Concurrent Namespace


GetConsumingEnumerable Method (CancellationToken)

[image]

.NET Framework Class Library
BlockingCollection<(Of <(T>)>)..::.GetConsumingEnumerable Method (CancellationToken)
BlockingCollection<(Of <(T>)>) Class See Also Send Feedback

Provides a consuming IEnumerable<(Of <(T>)>) for items in the collection. Calling MoveNext on the returned enumerable will block if there is no data available, or will throw an OperationCanceledException if the CancellationToken is canceled.

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

Syntax

Visual Basic (Declaration)
Public Function GetConsumingEnumerable ( _
    cancellationToken As CancellationToken _
) As IEnumerable(Of T)
C#
public IEnumerable<T> GetConsumingEnumerable(
    CancellationToken cancellationToken
)

Parameters

cancellationToken
Type: System.Threading..::.CancellationToken
A cancellation token to observe.

Return Value

An IEnumerable<(Of <(T>)>) that removes and returns items from the collection.

Exceptions

Exception | Condition
System..::.ObjectDisposedException | The BlockingCollection<(Of <(T>)>) has been disposed.
System..::.OperationCanceledException | If the CancellationToken is canceled.

See Also

BlockingCollection<(Of <(T>)>) Class
GetConsumingEnumerable Overload
System.Collections.Concurrent Namespace


Take Method

[image] [image]

.NET Framework Class Library
BlockingCollection<(Of <(T>)>)..::.Take Method
BlockingCollection<(Of <(T>)>) Class See Also Send Feedback

Overload List

Name | Description
Take()()() | Takes an item from the BlockingCollection<(Of <(T>)>).
Take(CancellationToken) | Takes an item from the BlockingCollection<(Of <(T>)>).

See Also

BlockingCollection<(Of <(T>)>) Class
System.Collections.Concurrent Namespace


Take Method

[image]

.NET Framework Class Library
BlockingCollection<(Of <(T>)>)..::.Take Method
BlockingCollection<(Of <(T>)>) Class See Also Send Feedback

Takes an item from the BlockingCollection<(Of <(T>)>).

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

Syntax

Visual Basic (Declaration)
Public Function Take As T
C#
public T Take()

Return Value

The item removed from the collection.

Remarks

A call to Take()()() may block until an item is available to be removed.

Exceptions

Exception | Condition
System..::.OperationCanceledException | The BlockingCollection<(Of <(T>)>) is empty and has been marked as complete with regards to additions.
System..::.ObjectDisposedException | The BlockingCollection<(Of <(T>)>) has been disposed.
System..::.InvalidOperationException | The underlying collection was modified outside of this BlockingCollection<(Of <(T>)>) instance.

See Also

BlockingCollection<(Of <(T>)>) Class
Take Overload
System.Collections.Concurrent Namespace


Take Method (CancellationToken)

[image]

.NET Framework Class Library
BlockingCollection<(Of <(T>)>)..::.Take Method (CancellationToken)
BlockingCollection<(Of <(T>)>) Class See Also Send Feedback

Takes an item from the BlockingCollection<(Of <(T>)>).

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

Syntax

Visual Basic (Declaration)
Public Function Take ( _
    cancellationToken As CancellationToken _
) As T
C#
public T Take(
    CancellationToken cancellationToken
)

Parameters

cancellationToken
Type: System.Threading..::.CancellationToken

Return Value

The item removed from the collection.

Remarks

A call to Take(CancellationToken) may block until an item is available to be removed.

Exceptions

Exception | Condition
System..::.OperationCanceledException | If the CancellationToken is canceled or the BlockingCollection<(Of <(T>)>) is empty and has been marked as complete with regards to additions.
System..::.ObjectDisposedException | The BlockingCollection<(Of <(T>)>) has been disposed.
System..::.InvalidOperationException | The underlying collection was modified outside of this BlockingCollection<(Of <(T>)>) instance.

See Also

BlockingCollection<(Of <(T>)>) Class
Take Overload
System.Collections.Concurrent Namespace


TakeFromAny Method

[image] [image]

.NET Framework Class Library
BlockingCollection<(Of <(T>)>)..::.TakeFromAny Method
BlockingCollection<(Of <(T>)>) Class See Also Send Feedback

Overload List

Name | Description
TakeFromAny(array<BlockingCollection<(Of <(T>)>)>[]()[], T%) | Takes an item from any one of the specified BlockingCollection<(Of <(T>)>) instances.
TakeFromAny(array<BlockingCollection<(Of <(T>)>)>[]()[], T%, CancellationToken) | Takes an item from any one of the specified BlockingCollection<(Of <(T>)>) instances. A OperationCanceledException is thrown if the CancellationToken is canceled.

See Also

BlockingCollection<(Of <(T>)>) Class
System.Collections.Concurrent Namespace


TakeFromAny Method (BlockingCollection(T)[], T)

[image]

.NET Framework Class Library
BlockingCollection<(Of <(T>)>)..::.TakeFromAny Method (array<BlockingCollection<(Of <(T>)>)>[]()[], T%)
BlockingCollection<(Of <(T>)>) Class See Also Send Feedback

Takes an item from any one of the specified BlockingCollection<(Of <(T>)>) instances.

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

Syntax

Visual Basic (Declaration)
Public Shared Function TakeFromAny ( _
    collections As BlockingCollection(Of T)(), _
    <OutAttribute> ByRef item As T _
) As Integer
C#
public static int TakeFromAny(
    BlockingCollection<T>[] collections,
    out T item
)

Parameters

collections
Type: array< System.Collections.Concurrent..::.BlockingCollection <(Of <( T >)>) >[]()[]
The array of collections.
item
Type: T %
The item removed from one of the collections.

Return Value

The index of the collection in the collections array from which the item was removed, or -1 if an item could not be removed.

Remarks

A call to TakeFromAny may block until an item is available to be removed.

Exceptions

Exception | Condition
System..::.ArgumentNullException | The collections argument is null.
System..::.ArgumentException | The collections argument is a 0-length array or contains a null element.
System..::.ObjectDisposedException | At least one of the BlockingCollection<(Of <(T>)>) instances has been disposed.
System..::.InvalidOperationException | At least one of the underlying collections was modified outside of its BlockingCollection<(Of <(T>)>) instance.
System..::.ArgumentOutOfRangeException | The count of collections is greater than the maximum size of 62 for STA and 63 for MTA.

See Also

BlockingCollection<(Of <(T>)>) Class
TakeFromAny Overload
System.Collections.Concurrent Namespace


TakeFromAny Method (BlockingCollection(T)[], T, CancellationToken)

[image]

.NET Framework Class Library
BlockingCollection<(Of <(T>)>)..::.TakeFromAny Method (array<BlockingCollection<(Of <(T>)>)>[]()[], T%, CancellationToken)
BlockingCollection<(Of <(T>)>) Class See Also Send Feedback

Takes an item from any one of the specified BlockingCollection<(Of <(T>)>) instances. A OperationCanceledException is thrown if the CancellationToken is canceled.

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

Syntax

Visual Basic (Declaration)
Public Shared Function TakeFromAny ( _
    collections As BlockingCollection(Of T)(), _
    <OutAttribute> ByRef item As T, _
    cancellationToken As CancellationToken _
) As Integer
C#
public static int TakeFromAny(
    BlockingCollection<T>[] collections,
    out T item,
    CancellationToken cancellationToken
)

Parameters

collections
Type: array< System.Collections.Concurrent..::.BlockingCollection <(Of <( T >)>) >[]()[]
The array of collections.
item
Type: T %
The item removed from one of the collections.
cancellationToken
Type: System.Threading..::.CancellationToken
A cancellation token to observe.

Return Value

The index of the collection in the collections array from which the item was removed, or -1 if an item could not be removed.

Remarks

A call to TakeFromAny may block until an item is available to be removed.

Exceptions

Exception | Condition
System..::.ArgumentNullException | The collections argument is null.
System..::.OperationCanceledException | If the CancellationToken is canceled.
System..::.ArgumentException | The collections argument is a 0-length array or contains a null element.
System..::.ObjectDisposedException | At least one of the BlockingCollection<(Of <(T>)>) instances has been disposed.
System..::.InvalidOperationException | At least one of the underlying collections was modified outside of its BlockingCollection<(Of <(T>)>) instance.
System..::.ArgumentOutOfRangeException | The count of collections is greater than the maximum size of 62 for STA and 63 for MTA.

See Also

BlockingCollection<(Of <(T>)>) Class
TakeFromAny Overload
System.Collections.Concurrent Namespace


ToArray Method

[image]

.NET Framework Class Library
BlockingCollection<(Of <(T>)>)..::.ToArray Method
BlockingCollection<(Of <(T>)>) Class See Also Send Feedback

Copies the items from the BlockingCollection<(Of <(T>)>) instance into a new array.

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

Syntax

Visual Basic (Declaration)
Public Function ToArray As T()
C#
public T[] ToArray()

Return Value

An array containing copies of the elements of the collection.

Remarks

The copied elements are not removed from the collection.

Exceptions

Exception | Condition
System..::.ObjectDisposedException | The BlockingCollection<(Of <(T>)>) has been disposed.

See Also

BlockingCollection<(Of <(T>)>) Class
System.Collections.Concurrent Namespace


TryAdd Method

[image] [image]

.NET Framework Class Library
BlockingCollection<(Of <(T>)>)..::.TryAdd Method
BlockingCollection<(Of <(T>)>) Class See Also Send Feedback

Overload List

Name | Description
TryAdd(T) | Attempts to add the specified item to the BlockingCollection<(Of <(T>)>).
TryAdd(T, Int32) | Attempts to add the specified item to the BlockingCollection<(Of <(T>)>).
TryAdd(T, TimeSpan) | Attempts to add the specified item to the BlockingCollection<(Of <(T>)>).
TryAdd(T, Int32, CancellationToken) | Attempts to add the specified item to the BlockingCollection<(Of <(T>)>). A OperationCanceledException is thrown if the CancellationToken is canceled.

See Also

BlockingCollection<(Of <(T>)>) Class
System.Collections.Concurrent Namespace


TryAdd Method (T)

[image]

.NET Framework Class Library
BlockingCollection<(Of <(T>)>)..::.TryAdd Method (T)
BlockingCollection<(Of <(T>)>) Class See Also Send Feedback

Attempts to add the specified item to the BlockingCollection<(Of <(T>)>).

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

Syntax

Visual Basic (Declaration)
Public Function TryAdd ( _
    item As T _
) As Boolean
C#
public bool TryAdd(
    T item
)

Parameters

item
Type: T
The item to be added to the collection.

Return Value

true if the item could be added; otherwise, false.

Exceptions

Exception | Condition
System..::.InvalidOperationException | The BlockingCollection<(Of <(T>)>) has been marked as complete with regards to additions.
System..::.ObjectDisposedException | The BlockingCollection<(Of <(T>)>) has been disposed.
System..::.InvalidOperationException | The underlying collection didn't accept the item.

See Also

BlockingCollection<(Of <(T>)>) Class
TryAdd Overload
System.Collections.Concurrent Namespace


TryAdd Method (T, Int32)

[image]

.NET Framework Class Library
BlockingCollection<(Of <(T>)>)..::.TryAdd Method (T, Int32)
BlockingCollection<(Of <(T>)>) Class See Also Send Feedback

Attempts to add the specified item to the BlockingCollection<(Of <(T>)>).

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

Syntax

Visual Basic (Declaration)
Public Function TryAdd ( _
    item As T, _
    millisecondsTimeout As Integer _
) As Boolean
C#
public bool TryAdd(
    T item,
    int millisecondsTimeout
)

Parameters

item
Type: T
The item to be added to the collection.
millisecondsTimeout
Type: System..::.Int32
The number of milliseconds to wait, or Infinite (-1) to wait indefinitely.

Return Value

true if the item could be added to the collection within the alloted time; otherwise, false.

Exceptions

Exception | Condition
System..::.InvalidOperationException | The BlockingCollection<(Of <(T>)>) has been marked as complete with regards to additions.
System..::.ObjectDisposedException | The BlockingCollection<(Of <(T>)>) has been disposed.
System..::.ArgumentOutOfRangeException | millisecondsTimeout is a negative number other than -1, which represents an infinite time-out.
System..::.InvalidOperationException | The underlying collection didn't accept the item.

See Also

BlockingCollection<(Of <(T>)>) Class
TryAdd Overload
System.Collections.Concurrent Namespace


TryAdd Method (T, TimeSpan)

[image]

.NET Framework Class Library
BlockingCollection<(Of <(T>)>)..::.TryAdd Method (T, TimeSpan)
BlockingCollection<(Of <(T>)>) Class See Also Send Feedback

Attempts to add the specified item to the BlockingCollection<(Of <(T>)>).

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

Syntax

Visual Basic (Declaration)
Public Function TryAdd ( _
    item As T, _
    timeout As TimeSpan _
) As Boolean
C#
public bool TryAdd(
    T item,
    TimeSpan timeout
)

Parameters

item
Type: T
The item to be added to the collection.
timeout
Type: System..::.TimeSpan
A TimeSpan that represents the number of milliseconds to wait, or a TimeSpan that represents -1 milliseconds to wait indefinitely.

Return Value

true if the item could be added to the collection within the alloted time; otherwise, false.

Exceptions

Exception | Condition
System..::.InvalidOperationException | The BlockingCollection<(Of <(T>)>) has been marked as complete with regards to additions.
System..::.ObjectDisposedException | The BlockingCollection<(Of <(T>)>) has been disposed.
System..::.ArgumentOutOfRangeException | timeout is a negative number other than -1 milliseconds, which represents an infinite time-out -or- timeout is greater than MaxValue.
System..::.InvalidOperationException | The underlying collection didn't accept the item.

See Also

BlockingCollection<(Of <(T>)>) Class
TryAdd Overload
System.Collections.Concurrent Namespace


TryAdd Method (T, Int32, CancellationToken)

[image]

.NET Framework Class Library
BlockingCollection<(Of <(T>)>)..::.TryAdd Method (T, Int32, CancellationToken)
BlockingCollection<(Of <(T>)>) Class See Also Send Feedback

Attempts to add the specified item to the BlockingCollection<(Of <(T>)>). A OperationCanceledException is thrown if the CancellationToken is canceled.

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

Syntax

Visual Basic (Declaration)
Public Function TryAdd ( _
    item As T, _
    millisecondsTimeout As Integer, _
    cancellationToken As CancellationToken _
) As Boolean
C#
public bool TryAdd(
    T item,
    int millisecondsTimeout,
    CancellationToken cancellationToken
)

Parameters

item
Type: T
The item to be added to the collection.
millisecondsTimeout
Type: System..::.Int32
The number of milliseconds to wait, or Infinite (-1) to wait indefinitely.
cancellationToken
Type: System.Threading..::.CancellationToken
A cancellation token to observe.

Return Value

true if the item could be added to the collection within the alloted time; otherwise, false.

Exceptions

Exception | Condition
System..::.OperationCanceledException | If the CancellationToken is canceled.
System..::.InvalidOperationException | The BlockingCollection<(Of <(T>)>) has been marked as complete with regards to additions.
System..::.ObjectDisposedException | The BlockingCollection<(Of <(T>)>) has been disposed.
System..::.ArgumentOutOfRangeException | millisecondsTimeout is a negative number other than -1, which represents an infinite time-out.
System..::.InvalidOperationException | The underlying collection didn't accept the item.

See Also

BlockingCollection<(Of <(T>)>) Class
TryAdd Overload
System.Collections.Concurrent Namespace


TryAddToAny Method

[image] [image]

.NET Framework Class Library
BlockingCollection<(Of <(T>)>)..::.TryAddToAny Method
BlockingCollection<(Of <(T>)>) Class See Also Send Feedback

Overload List

Name | Description
TryAddToAny(array<BlockingCollection<(Of <(T>)>)>[]()[], T) | Attempts to add the specified item to any one of the specified BlockingCollection<(Of <(T>)>) instances.
TryAddToAny(array<BlockingCollection<(Of <(T>)>)>[]()[], T, Int32) | Attempts to add the specified item to any one of the specified BlockingCollection<(Of <(T>)>) instances.
TryAddToAny(array<BlockingCollection<(Of <(T>)>)>[]()[], T, TimeSpan) | Attempts to add the specified item to any one of the specified BlockingCollection<(Of <(T>)>) instances.
TryAddToAny(array<BlockingCollection<(Of <(T>)>)>[]()[], T, Int32, CancellationToken) | Attempts to add the specified item to any one of the specified BlockingCollection<(Of <(T>)>) instances. A OperationCanceledException is thrown if the CancellationToken is canceled.

See Also

BlockingCollection<(Of <(T>)>) Class
System.Collections.Concurrent Namespace


TryAddToAny Method (BlockingCollection(T)[], T)

[image]

.NET Framework Class Library
BlockingCollection<(Of <(T>)>)..::.TryAddToAny Method (array<BlockingCollection<(Of <(T>)>)>[]()[], T)
BlockingCollection<(Of <(T>)>) Class See Also Send Feedback

Attempts to add the specified item to any one of the specified BlockingCollection<(Of <(T>)>) instances.

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

Syntax

Visual Basic (Declaration)
Public Shared Function TryAddToAny ( _
    collections As BlockingCollection(Of T)(), _
    item As T _
) As Integer
C#
public static int TryAddToAny(
    BlockingCollection<T>[] collections,
    T item
)

Parameters

collections
Type: array< System.Collections.Concurrent..::.BlockingCollection <(Of <( T >)>) >[]()[]
The array of collections.
item
Type: T
The item to be added to one of the collections.

Return Value

The index of the collection in the collections array to which the item was added, or -1 if the item could not be added.

Exceptions

Exception | Condition
System..::.ArgumentNullException | The collections argument is null.
System..::.ArgumentException | The collections argument is a 0-length array or contains a null element, or at least one of collections has been marked as complete for adding.
System..::.ObjectDisposedException | At least one of the BlockingCollection<(Of <(T>)>) instances has been disposed.
System..::.InvalidOperationException | At least one underlying collection didn't accept the item.
System..::.ArgumentOutOfRangeException | The count of collections is greater than the maximum size of 62 for STA and 63 for MTA.

See Also

BlockingCollection<(Of <(T>)>) Class
TryAddToAny Overload
System.Collections.Concurrent Namespace


TryAddToAny Method (BlockingCollection(T)[], T, Int32)

[image]

.NET Framework Class Library
BlockingCollection<(Of <(T>)>)..::.TryAddToAny Method (array<BlockingCollection<(Of <(T>)>)>[]()[], T, Int32)
BlockingCollection<(Of <(T>)>) Class See Also Send Feedback

Attempts to add the specified item to any one of the specified BlockingCollection<(Of <(T>)>) instances.

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

Syntax

Visual Basic (Declaration)
Public Shared Function TryAddToAny ( _
    collections As BlockingCollection(Of T)(), _
    item As T, _
    millisecondsTimeout As Integer _
) As Integer
C#
public static int TryAddToAny(
    BlockingCollection<T>[] collections,
    T item,
    int millisecondsTimeout
)

Parameters

collections
Type: array< System.Collections.Concurrent..::.BlockingCollection <(Of <( T >)>) >[]()[]
The array of collections.
item
Type: T
The item to be added to one of the collections.
millisecondsTimeout
Type: System..::.Int32
The number of milliseconds to wait, or Infinite (-1) to wait indefinitely.

Return Value

The index of the collection in the collections array to which the item was added, or -1 if the item could not be added.

Exceptions

Exception | Condition
System..::.ArgumentNullException | The collections argument is null.
System..::.ArgumentException | The collections argument is a 0-length array or contains a null element, or at least one of collections has been marked as complete for adding.
System..::.ObjectDisposedException | At least one of the BlockingCollection<(Of <(T>)>) instances has been disposed.
System..::.ArgumentOutOfRangeException | millisecondsTimeout is a negative number other than -1, which represents an infinite time-out.
System..::.InvalidOperationException | At least one underlying collection didn't accept the item.
System..::.ArgumentOutOfRangeException | The count of collections is greater than the maximum size of 62 for STA and 63 for MTA.

See Also

BlockingCollection<(Of <(T>)>) Class
TryAddToAny Overload
System.Collections.Concurrent Namespace


TryAddToAny Method (BlockingCollection(T)[], T, TimeSpan)

[image]

.NET Framework Class Library
BlockingCollection<(Of <(T>)>)..::.TryAddToAny Method (array<BlockingCollection<(Of <(T>)>)>[]()[], T, TimeSpan)
BlockingCollection<(Of <(T>)>) Class See Also Send Feedback

Attempts to add the specified item to any one of the specified BlockingCollection<(Of <(T>)>) instances.

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

Syntax

Visual Basic (Declaration)
Public Shared Function TryAddToAny ( _
    collections As BlockingCollection(Of T)(), _
    item As T, _
    timeout As TimeSpan _
) As Integer
C#
public static int TryAddToAny(
    BlockingCollection<T>[] collections,
    T item,
    TimeSpan timeout
)

Parameters

collections
Type: array< System.Collections.Concurrent..::.BlockingCollection <(Of <( T >)>) >[]()[]
The array of collections.
item
Type: T
The item to be added to one of the collections.
timeout
Type: System..::.TimeSpan
A TimeSpan that represents the number of milliseconds to wait, or a TimeSpan that represents -1 milliseconds to wait indefinitely.

Return Value

The index of the collection in the collections array to which the item was added, or -1 if the item could not be added.

Exceptions

Exception | Condition
System..::.ArgumentNullException | The collections argument is null.
System..::.ArgumentException | The collections argument is a 0-length array or contains a null element, or at least one of collections has been marked as complete for adding.
System..::.ObjectDisposedException | At least one of the BlockingCollection<(Of <(T>)>) instances has been disposed.
System..::.ArgumentOutOfRangeException | timeout is a negative number other than -1 milliseconds, which represents an infinite time-out -or- timeout is greater than MaxValue.
System..::.InvalidOperationException | At least one underlying collection didn't accept the item.
System..::.ArgumentOutOfRangeException | The count of collections is greater than the maximum size of 62 for STA and 63 for MTA.

See Also

BlockingCollection<(Of <(T>)>) Class
TryAddToAny Overload
System.Collections.Concurrent Namespace


TryAddToAny Method (BlockingCollection(T)[], T, Int32, CancellationToken)

[image]

.NET Framework Class Library
BlockingCollection<(Of <(T>)>)..::.TryAddToAny Method (array<BlockingCollection<(Of <(T>)>)>[]()[], T, Int32, CancellationToken)
BlockingCollection<(Of <(T>)>) Class See Also Send Feedback

Attempts to add the specified item to any one of the specified BlockingCollection<(Of <(T>)>) instances. A OperationCanceledException is thrown if the CancellationToken is canceled.

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

Syntax

Visual Basic (Declaration)
Public Shared Function TryAddToAny ( _
    collections As BlockingCollection(Of T)(), _
    item As T, _
    millisecondsTimeout As Integer, _
    cancellationToken As CancellationToken _
) As Integer
C#
public static int TryAddToAny(
    BlockingCollection<T>[] collections,
    T item,
    int millisecondsTimeout,
    CancellationToken cancellationToken
)

Parameters

collections
Type: array< System.Collections.Concurrent..::.BlockingCollection <(Of <( T >)>) >[]()[]
The array of collections.
item
Type: T
The item to be added to one of the collections.
millisecondsTimeout
Type: System..::.Int32
The number of milliseconds to wait, or Infinite (-1) to wait indefinitely.
cancellationToken
Type: System.Threading..::.CancellationToken
A cancellation token to observe.

Return Value

The index of the collection in the collections array to which the item was added, or -1 if the item could not be added.

Exceptions

Exception | Condition
System..::.OperationCanceledException | If the CancellationToken is canceled.
System..::.ArgumentNullException | The collections argument is null.
System..::.ArgumentException | The collections argument is a 0-length array or contains a null element, or at least one of collections has been marked as complete for adding.
System..::.ObjectDisposedException | At least one of the BlockingCollection<(Of <(T>)>) instances has been disposed.
System..::.ArgumentOutOfRangeException | millisecondsTimeout is a negative number other than -1, which represents an infinite time-out.
System..::.InvalidOperationException | At least one underlying collection didn't accept the item.
System..::.ArgumentOutOfRangeException | The count of collections is greater than the maximum size of 62 for STA and 63 for MTA.

See Also

BlockingCollection<(Of <(T>)>) Class
TryAddToAny Overload
System.Collections.Concurrent Namespace


TryTake Method

[image] [image]

.NET Framework Class Library
BlockingCollection<(Of <(T>)>)..::.TryTake Method
BlockingCollection<(Of <(T>)>) Class See Also Send Feedback

Overload List

Name | Description
TryTake(T%) | Attempts to remove an item from the BlockingCollection<(Of <(T>)>).
TryTake(T%, Int32) | Attempts to remove an item from the BlockingCollection<(Of <(T>)>).
TryTake(T%, TimeSpan) | Attempts to remove an item from the BlockingCollection<(Of <(T>)>).
TryTake(T%, Int32, CancellationToken) | Attempts to remove an item from the BlockingCollection<(Of <(T>)>). A OperationCanceledException is thrown if the CancellationToken is canceled.

See Also

BlockingCollection<(Of <(T>)>) Class
System.Collections.Concurrent Namespace


TryTake Method (T)

[image]

.NET Framework Class Library
BlockingCollection<(Of <(T>)>)..::.TryTake Method (T%)
BlockingCollection<(Of <(T>)>) Class See Also Send Feedback

Attempts to remove an item from the BlockingCollection<(Of <(T>)>).

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

Syntax

Visual Basic (Declaration)
Public Function TryTake ( _
    <OutAttribute> ByRef item As T _
) As Boolean
C#
public bool TryTake(
    out T item
)

Parameters

item
Type: T %
The item removed from the collection.

Return Value

true if an item could be removed; otherwise, false.

Exceptions

Exception | Condition
System..::.ObjectDisposedException | The BlockingCollection<(Of <(T>)>) has been disposed.
System..::.InvalidOperationException | The underlying collection was modified outside of this BlockingCollection<(Of <(T>)>) instance.

See Also

BlockingCollection<(Of <(T>)>) Class
TryTake Overload
System.Collections.Concurrent Namespace


TryTake Method (T, Int32)

[image]

.NET Framework Class Library
BlockingCollection<(Of <(T>)>)..::.TryTake Method (T%, Int32)
BlockingCollection<(Of <(T>)>) Class See Also Send Feedback

Attempts to remove an item from the BlockingCollection<(Of <(T>)>).

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

Syntax

Visual Basic (Declaration)
Public Function TryTake ( _
    <OutAttribute> ByRef item As T, _
    millisecondsTimeout As Integer _
) As Boolean
C#
public bool TryTake(
    out T item,
    int millisecondsTimeout
)

Parameters

item
Type: T %
The item removed from the collection.
millisecondsTimeout
Type: System..::.Int32
The number of milliseconds to wait, or Infinite (-1) to wait indefinitely.

Return Value

true if an item could be removed from the collection within the alloted time; otherwise, false.

Exceptions

Exception | Condition
System..::.ObjectDisposedException | The BlockingCollection<(Of <(T>)>) has been disposed.
System..::.ArgumentOutOfRangeException | millisecondsTimeout is a negative number other than -1, which represents an infinite time-out.
System..::.InvalidOperationException | The underlying collection was modified outside of this BlockingCollection<(Of <(T>)>) instance.

See Also

BlockingCollection<(Of <(T>)>) Class
TryTake Overload
System.Collections.Concurrent Namespace


TryTake Method (T, TimeSpan)

[image]

.NET Framework Class Library
BlockingCollection<(Of <(T>)>)..::.TryTake Method (T%, TimeSpan)
BlockingCollection<(Of <(T>)>) Class See Also Send Feedback

Attempts to remove an item from the BlockingCollection<(Of <(T>)>).

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

Syntax

Visual Basic (Declaration)
Public Function TryTake ( _
    <OutAttribute> ByRef item As T, _
    timeout As TimeSpan _
) As Boolean
C#
public bool TryTake(
    out T item,
    TimeSpan timeout
)

Parameters

item
Type: T %
The item removed from the collection.
timeout
Type: System..::.TimeSpan
A TimeSpan that represents the number of milliseconds to wait, or a TimeSpan that represents -1 milliseconds to wait indefinitely.

Return Value

true if an item could be removed from the collection within the alloted time; otherwise, false.

Exceptions

Exception | Condition
System..::.ObjectDisposedException | The BlockingCollection<(Of <(T>)>) has been disposed.
System..::.ArgumentOutOfRangeException | timeout is a negative number other than -1 milliseconds, which represents an infinite time-out -or- timeout is greater than MaxValue.
System..::.InvalidOperationException | The underlying collection was modified outside of this BlockingCollection<(Of <(T>)>) instance.

See Also

BlockingCollection<(Of <(T>)>) Class
TryTake Overload
System.Collections.Concurrent Namespace


TryTake Method (T, Int32, CancellationToken)

[image]

.NET Framework Class Library
BlockingCollection<(Of <(T>)>)..::.TryTake Method (T%, Int32, CancellationToken)
BlockingCollection<(Of <(T>)>) Class See Also Send Feedback

Attempts to remove an item from the BlockingCollection<(Of <(T>)>). A OperationCanceledException is thrown if the CancellationToken is canceled.

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

Syntax

Visual Basic (Declaration)
Public Function TryTake ( _
    <OutAttribute> ByRef item As T, _
    millisecondsTimeout As Integer, _
    cancellationToken As CancellationToken _
) As Boolean
C#
public bool TryTake(
    out T item,
    int millisecondsTimeout,
    CancellationToken cancellationToken
)

Parameters

item
Type: T %
The item removed from the collection.
millisecondsTimeout
Type: System..::.Int32
The number of milliseconds to wait, or Infinite (-1) to wait indefinitely.
cancellationToken
Type: System.Threading..::.CancellationToken
A cancellation token to observe.

Return Value

true if an item could be removed from the collection within the alloted time; otherwise, false.

Exceptions

Exception | Condition
System..::.OperationCanceledException | If the CancellationToken is canceled.
System..::.ObjectDisposedException | The BlockingCollection<(Of <(T>)>) has been disposed.
System..::.ArgumentOutOfRangeException | millisecondsTimeout is a negative number other than -1, which represents an infinite time-out.
System..::.InvalidOperationException | The underlying collection was modified outside of this BlockingCollection<(Of <(T>)>) instance.

See Also

BlockingCollection<(Of <(T>)>) Class
TryTake Overload
System.Collections.Concurrent Namespace


TryTakeFromAny Method

[image] [image]

.NET Framework Class Library
BlockingCollection<(Of <(T>)>)..::.TryTakeFromAny Method
BlockingCollection<(Of <(T>)>) Class See Also Send Feedback

Overload List

Name | Description
TryTakeFromAny(array<BlockingCollection<(Of <(T>)>)>[]()[], T%) | Attempts to remove an item from any one of the specified BlockingCollection<(Of <(T>)>) instances.
TryTakeFromAny(array<BlockingCollection<(Of <(T>)>)>[]()[], T%, Int32) | Attempts to remove an item from any one of the specified BlockingCollection<(Of <(T>)>) instances.
TryTakeFromAny(array<BlockingCollection<(Of <(T>)>)>[]()[], T%, TimeSpan) | Attempts to remove an item from any one of the specified BlockingCollection<(Of <(T>)>) instances.
TryTakeFromAny(array<BlockingCollection<(Of <(T>)>)>[]()[], T%, Int32, CancellationToken) | Attempts to remove an item from any one of the specified BlockingCollection<(Of <(T>)>) instances. A OperationCanceledException is thrown if the CancellationToken is canceled.

See Also

BlockingCollection<(Of <(T>)>) Class
System.Collections.Concurrent Namespace


TryTakeFromAny Method (BlockingCollection(T)[], T)

[image]

.NET Framework Class Library
BlockingCollection<(Of <(T>)>)..::.TryTakeFromAny Method (array<BlockingCollection<(Of <(T>)>)>[]()[], T%)
BlockingCollection<(Of <(T>)>) Class See Also Send Feedback

Attempts to remove an item from any one of the specified BlockingCollection<(Of <(T>)>) instances.

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

Syntax

Visual Basic (Declaration)
Public Shared Function TryTakeFromAny ( _
    collections As BlockingCollection(Of T)(), _
    <OutAttribute> ByRef item As T _
) As Integer
C#
public static int TryTakeFromAny(
    BlockingCollection<T>[] collections,
    out T item
)

Parameters

collections
Type: array< System.Collections.Concurrent..::.BlockingCollection <(Of <( T >)>) >[]()[]
The array of collections.
item
Type: T %
The item removed from one of the collections.

Return Value

The index of the collection in the collections array from which the item was removed, or -1 if an item could not be removed.

Remarks

A call to TryTakeFromAny may block until an item is available to be removed.

Exceptions

Exception | Condition
System..::.ArgumentNullException | The collections argument is null.
System..::.ArgumentException | The collections argument is a 0-length array or contains a null element.
System..::.ObjectDisposedException | At least one of the BlockingCollection<(Of <(T>)>) instances has been disposed.
System..::.InvalidOperationException | At least one of the underlying collections was modified outside of its BlockingCollection<(Of <(T>)>) instance.
System..::.ArgumentOutOfRangeException | The count of collections is greater than the maximum size of 62 for STA and 63 for MTA.

See Also

BlockingCollection<(Of <(T>)>) Class
TryTakeFromAny Overload
System.Collections.Concurrent Namespace


TryTakeFromAny Method (BlockingCollection(T)[], T, Int32)

[image]

.NET Framework Class Library
BlockingCollection<(Of <(T>)>)..::.TryTakeFromAny Method (array<BlockingCollection<(Of <(T>)>)>[]()[], T%, Int32)
BlockingCollection<(Of <(T>)>) Class See Also Send Feedback

Attempts to remove an item from any one of the specified BlockingCollection<(Of <(T>)>) instances.

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

Syntax

Visual Basic (Declaration)
Public Shared Function TryTakeFromAny ( _
    collections As BlockingCollection(Of T)(), _
    <OutAttribute> ByRef item As T, _
    millisecondsTimeout As Integer _
) As Integer
C#
public static int TryTakeFromAny(
    BlockingCollection<T>[] collections,
    out T item,
    int millisecondsTimeout
)

Parameters

collections
Type: array< System.Collections.Concurrent..::.BlockingCollection <(Of <( T >)>) >[]()[]
The array of collections.
item
Type: T %
The item removed from one of the collections.
millisecondsTimeout
Type: System..::.Int32
The number of milliseconds to wait, or Infinite (-1) to wait indefinitely.

Return Value

The index of the collection in the collections array from which the item was removed, or -1 if an item could not be removed.

Remarks

A call to TryTakeFromAny may block until an item is available to be removed.

Exceptions

Exception | Condition
System..::.ArgumentNullException | The collections argument is null.
System..::.ArgumentException | The collections argument is a 0-length array or contains a null element.
System..::.ObjectDisposedException | At least one of the BlockingCollection<(Of <(T>)>) instances has been disposed.
System..::.ArgumentOutOfRangeException | millisecondsTimeout is a negative number other than -1, which represents an infinite time-out.
System..::.InvalidOperationException | At least one of the underlying collections was modified outside of its BlockingCollection<(Of <(T>)>) instance.
System..::.ArgumentOutOfRangeException | The count of collections is greater than the maximum size of 62 for STA and 63 for MTA.

See Also

BlockingCollection<(Of <(T>)>) Class
TryTakeFromAny Overload
System.Collections.Concurrent Namespace


TryTakeFromAny Method (BlockingCollection(T)[], T, TimeSpan)

[image]

.NET Framework Class Library
BlockingCollection<(Of <(T>)>)..::.TryTakeFromAny Method (array<BlockingCollection<(Of <(T>)>)>[]()[], T%, TimeSpan)
BlockingCollection<(Of <(T>)>) Class See Also Send Feedback

Attempts to remove an item from any one of the specified BlockingCollection<(Of <(T>)>) instances.

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

Syntax

Visual Basic (Declaration)
Public Shared Function TryTakeFromAny ( _
    collections As BlockingCollection(Of T)(), _
    <OutAttribute> ByRef item As T, _
    timeout As TimeSpan _
) As Integer
C#
public static int TryTakeFromAny(
    BlockingCollection<T>[] collections,
    out T item,
    TimeSpan timeout
)

Parameters

collections
Type: array< System.Collections.Concurrent..::.BlockingCollection <(Of <( T >)>) >[]()[]
The array of collections.
item
Type: T %
The item removed from one of the collections.
timeout
Type: System..::.TimeSpan
A TimeSpan that represents the number of milliseconds to wait, or a TimeSpan that represents -1 milliseconds to wait indefinitely.

Return Value

The index of the collection in the collections array from which the item was removed, or -1 if an item could not be removed.

Remarks

A call to TryTakeFromAny may block until an item is available to be removed.

Exceptions

Exception | Condition
System..::.ArgumentNullException | The collections argument is null.
System..::.ArgumentException | The collections argument is a 0-length array or contains a null element.
System..::.ObjectDisposedException | At least one of the BlockingCollection<(Of <(T>)>) instances has been disposed.
System..::.ArgumentOutOfRangeException | timeout is a negative number other than -1 milliseconds, which represents an infinite time-out -or- timeout is greater than MaxValue.
System..::.InvalidOperationException | At least one of the underlying collections was modified outside of its BlockingCollection<(Of <(T>)>) instance.
System..::.ArgumentOutOfRangeException | The count of collections is greater than the maximum size of 62 for STA and 63 for MTA.

See Also

BlockingCollection<(Of <(T>)>) Class
TryTakeFromAny Overload
System.Collections.Concurrent Namespace


TryTakeFromAny Method (BlockingCollection(T)[], T, Int32, CancellationToken)

[image]

.NET Framework Class Library
BlockingCollection<(Of <(T>)>)..::.TryTakeFromAny Method (array<BlockingCollection<(Of <(T>)>)>[]()[], T%, Int32, CancellationToken)
BlockingCollection<(Of <(T>)>) Class See Also Send Feedback

Attempts to remove an item from any one of the specified BlockingCollection<(Of <(T>)>) instances. A OperationCanceledException is thrown if the CancellationToken is canceled.

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

Syntax

Visual Basic (Declaration)
Public Shared Function TryTakeFromAny ( _
    collections As BlockingCollection(Of T)(), _
    <OutAttribute> ByRef item As T, _
    millisecondsTimeout As Integer, _
    cancellationToken As CancellationToken _
) As Integer
C#
public static int TryTakeFromAny(
    BlockingCollection<T>[] collections,
    out T item,
    int millisecondsTimeout,
    CancellationToken cancellationToken
)

Parameters

collections
Type: array< System.Collections.Concurrent..::.BlockingCollection <(Of <( T >)>) >[]()[]
The array of collections.
item
Type: T %
The item removed from one of the collections.
millisecondsTimeout
Type: System..::.Int32
The number of milliseconds to wait, or Infinite (-1) to wait indefinitely.
cancellationToken
Type: System.Threading..::.CancellationToken
A cancellation token to observe.

Return Value

The index of the collection in the collections array from which the item was removed, or -1 if an item could not be removed.

Remarks

A call to TryTakeFromAny may block until an item is available to be removed.

Exceptions

Exception | Condition
System..::.OperationCanceledException | If the CancellationToken is canceled.
System..::.ArgumentNullException | The collections argument is null.
System..::.ArgumentException | The collections argument is a 0-length array or contains a null element.
System..::.ObjectDisposedException | At least one of the BlockingCollection<(Of <(T>)>) instances has been disposed.
System..::.ArgumentOutOfRangeException | millisecondsTimeout is a negative number other than -1, which represents an infinite time-out.
System..::.InvalidOperationException | At least one of the underlying collections was modified outside of its BlockingCollection<(Of <(T>)>) instance.
System..::.ArgumentOutOfRangeException | The count of collections is greater than the maximum size of 62 for STA and 63 for MTA.

See Also

BlockingCollection<(Of <(T>)>) Class
TryTakeFromAny Overload
System.Collections.Concurrent Namespace


BlockingCollection(T) Properties

[image] [image]

.NET Framework Class Library
BlockingCollection<(Of <(T>)>) Properties
BlockingCollection<(Of <(T>)>) Class See Also Send Feedback

The BlockingCollection<(Of <(T>)>) type exposes the following members.

Properties

Name | Description
BoundedCapacity | Gets the bounded capacity of this BlockingCollection<(Of <(T>)>) instance.
Count | Gets the number of items contained in the BlockingCollection<(Of <(T>)>).
IsAddingCompleted | Gets whether this BlockingCollection<(Of <(T>)>) has been marked as complete for adding.
IsCompleted | Gets whether this BlockingCollection<(Of <(T>)>) has been marked as complete for adding and is empty.

Explicit Interface Implementations

Name | Description
ICollection..::.IsSynchronized | Gets a value indicating whether access to the ICollection is synchronized.
ICollection..::.SyncRoot | Gets an object that can be used to synchronize access to the ICollection. This property is not supported.

See Also

BlockingCollection<(Of <(T>)>) Class
System.Collections.Concurrent Namespace


ICollection.IsSynchronized Property

[image]

.NET Framework Class Library
BlockingCollection<(Of <(T>)>)..::.ICollection..::.IsSynchronized Property
BlockingCollection<(Of <(T>)>) Class See Also Send Feedback

Gets a value indicating whether access to the ICollection is synchronized.

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

Syntax

Visual Basic (Declaration)
Private ReadOnly Property IsSynchronized As Boolean
    Implements ICollection.IsSynchronized
C#
bool ICollection.IsSynchronized { get; }

Implements

ICollection..::.IsSynchronized

Exceptions

Exception | Condition
System..::.ObjectDisposedException | The BlockingCollection<(Of <(T>)>) has been disposed.

See Also

BlockingCollection<(Of <(T>)>) Class
System.Collections.Concurrent Namespace


ICollection.SyncRoot Property

[image]

.NET Framework Class Library
BlockingCollection<(Of <(T>)>)..::.ICollection..::.SyncRoot Property
BlockingCollection<(Of <(T>)>) Class See Also Send Feedback

Gets an object that can be used to synchronize access to the ICollection. This property is not supported.

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

Syntax

Visual Basic (Declaration)
Private ReadOnly Property SyncRoot As Object
    Implements ICollection.SyncRoot
C#
Object ICollection.SyncRoot { get; }

Implements

ICollection..::.SyncRoot

Exceptions

Exception | Condition
System..::.NotSupportedException | The SyncRoot property is not supported.

See Also

BlockingCollection<(Of <(T>)>) Class
System.Collections.Concurrent Namespace


BoundedCapacity Property

[image]

.NET Framework Class Library
BlockingCollection<(Of <(T>)>)..::.BoundedCapacity Property
BlockingCollection<(Of <(T>)>) Class See Also Send Feedback

Gets the bounded capacity of this BlockingCollection<(Of <(T>)>) instance.

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

Syntax

Visual Basic (Declaration)
Public ReadOnly Property BoundedCapacity As Integer
C#
public int BoundedCapacity { get; }

Field Value

The bounded capacity of this collection, or int.MaxValue if no bound was supplied.

Exceptions

Exception | Condition
System..::.ObjectDisposedException | The BlockingCollection<(Of <(T>)>) has been disposed.

See Also

BlockingCollection<(Of <(T>)>) Class
System.Collections.Concurrent Namespace


Count Property

[image]

.NET Framework Class Library
BlockingCollection<(Of <(T>)>)..::.Count Property
BlockingCollection<(Of <(T>)>) Class See Also Send Feedback

Gets the number of items contained in the BlockingCollection<(Of <(T>)>).

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

Syntax

Visual Basic (Declaration)
Public ReadOnly Property Count As Integer
C#
public int Count { get; }

Field Value

The number of items contained in the BlockingCollection<(Of <(T>)>).

Implements

ICollection..::.Count

Exceptions

Exception | Condition
System..::.ObjectDisposedException | The BlockingCollection<(Of <(T>)>) has been disposed.

See Also

BlockingCollection<(Of <(T>)>) Class
System.Collections.Concurrent Namespace


IsAddingCompleted Property

[image]

.NET Framework Class Library
BlockingCollection<(Of <(T>)>)..::.IsAddingCompleted Property
BlockingCollection<(Of <(T>)>) Class See Also Send Feedback

Gets whether this BlockingCollection<(Of <(T>)>) has been marked as complete for adding.

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

Syntax

Visual Basic (Declaration)
Public ReadOnly Property IsAddingCompleted As Boolean
C#
public bool IsAddingCompleted { get; }

Field Value

Whether this collection has been marked as complete for adding.

Exceptions

Exception | Condition
System..::.ObjectDisposedException | The BlockingCollection<(Of <(T>)>) has been disposed.

See Also

BlockingCollection<(Of <(T>)>) Class
System.Collections.Concurrent Namespace


IsCompleted Property

[image]

.NET Framework Class Library
BlockingCollection<(Of <(T>)>)..::.IsCompleted Property
BlockingCollection<(Of <(T>)>) Class See Also Send Feedback

Gets whether this BlockingCollection<(Of <(T>)>) has been marked as complete for adding and is empty.

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

Syntax

Visual Basic (Declaration)
Public ReadOnly Property IsCompleted As Boolean
C#
public bool IsCompleted { get; }

Field Value

Whether this collection has been marked as complete for adding and is empty.

Exceptions

Exception | Condition
System..::.ObjectDisposedException | The BlockingCollection<(Of <(T>)>) has been disposed.

See Also

BlockingCollection<(Of <(T>)>) Class
System.Collections.Concurrent Namespace


ConcurrentBag(T) Class

[image]

.NET Framework Class Library
ConcurrentBag<(Of <(T>)>) Class
See Also Send Feedback

Represents an thread-safe, unordered collection of objects.

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

Syntax

Visual Basic (Declaration)
<SerializableAttribute> _
<ComVisibleAttribute(False)> _
<HostProtectionAttribute(SecurityAction.LinkDemand, Synchronization := True,  _
    ExternalThreading := True)> _
Public Class ConcurrentBag(Of T) _
    Implements IProducerConsumerCollection(Of T), IEnumerable(Of T),  _
    ICollection, IEnumerable
C#
[SerializableAttribute]
[ComVisibleAttribute(false)]
[HostProtectionAttribute(SecurityAction.LinkDemand, Synchronization = true,
    ExternalThreading = true)]
public class ConcurrentBag<T> : IProducerConsumerCollection<T>,
    IEnumerable<T>, ICollection, IEnumerable

Type Parameters

T
Specifies the type of elements in the bag.

Remarks

Bags are useful for storing objects when ordering doesn't matter, and unlike sets, bags support duplicates. ConcurrentBag<(Of <(T>)>) is a thread-safe bag implementation, optimized for scenarios where the same thread will be both producing and consuming data stored in the bag.

ConcurrentBag<(Of <(T>)>) accepts null reference (Nothing in Visual Basic) as a valid value for reference types.

All public and protected members of ConcurrentBag<(Of <(T>)>) are thread-safe and may be used concurrently from multiple threads.

Inheritance Hierarchy

System..::.Object
System.Collections.Concurrent..::.ConcurrentBag<(Of <(T>)>)

See Also

System.Collections.Concurrent Namespace


ConcurrentBag(T) Constructor

[image] [image]

.NET Framework Class Library
ConcurrentBag<(Of <(T>)>) Constructor
ConcurrentBag<(Of <(T>)>) Class See Also Send Feedback

Overload List

Name | Description
ConcurrentBag<(Of <(T>)>)()()() | Initializes a new instance of the ConcurrentBag<(Of <(T>)>) class.
ConcurrentBag<(Of <(T>)>)(IEnumerable<(Of <(T>)>)) | Initializes a new instance of the ConcurrentBag<(Of <(T>)>) class that contains elements copied from the specified collection.

See Also

ConcurrentBag<(Of <(T>)>) Class
System.Collections.Concurrent Namespace


ConcurrentBag(T) Constructor

[image]

.NET Framework Class Library
ConcurrentBag<(Of <(T>)>) Constructor
ConcurrentBag<(Of <(T>)>) Class See Also Send Feedback

Initializes a new instance of the ConcurrentBag<(Of <(T>)>) class.

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

Syntax

Visual Basic (Declaration)
Public Sub New
C#
public ConcurrentBag()

See Also

ConcurrentBag<(Of <(T>)>) Class
ConcurrentBag<(Of <(T>)>) Overload
System.Collections.Concurrent Namespace


ConcurrentBag(T) Constructor (IEnumerable(T))

[image]

.NET Framework Class Library
ConcurrentBag<(Of <(T>)>) Constructor (IEnumerable<(Of <(T>)>))
ConcurrentBag<(Of <(T>)>) Class See Also Send Feedback

Initializes a new instance of the ConcurrentBag<(Of <(T>)>) class that contains elements copied from the specified collection.

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

Syntax

Visual Basic (Declaration)
Public Sub New ( _
    collection As IEnumerable(Of T) _
)
C#
public ConcurrentBag(
    IEnumerable<T> collection
)

Parameters

collection
Type: System.Collections.Generic..::.IEnumerable<(Of <( T >)>)
The collection whose elements are copied to the new ConcurrentBag<(Of <(T>)>).

Exceptions

Exception | Condition
System..::.ArgumentNullException | collection is a null reference (Nothing in Visual Basic).

See Also

ConcurrentBag<(Of <(T>)>) Class
ConcurrentBag<(Of <(T>)>) Overload
System.Collections.Concurrent Namespace


ConcurrentBag(T) Methods

[image] [image]

.NET Framework Class Library
ConcurrentBag<(Of <(T>)>) Methods
ConcurrentBag<(Of <(T>)>) Class See Also Send Feedback

The ConcurrentBag<(Of <(T>)>) type exposes the following members.

Methods

Name | Description
Add | Adds an object to the ConcurrentBag<(Of <(T>)>).
CopyTo | Copies the ConcurrentBag<(Of <(T>)>) elements to an existing one-dimensional Array, starting at the specified array index.
Equals | (Inherited from Object.)
Finalize | (Inherited from Object.)
GetEnumerator | Returns an enumerator that iterates through the ConcurrentBag<(Of <(T>)>).
GetHashCode | (Inherited from Object.)
GetType | (Inherited from Object.)
MemberwiseClone | (Inherited from Object.)
ToArray | Copies the ConcurrentBag<(Of <(T>)>) elements to a new array.
ToString | (Inherited from Object.)
TryPeek | Attempts to return an object from the ConcurrentBag<(Of <(T>)>) without removing it.
TryTake | Attempts to remove and return an object from the ConcurrentBag<(Of <(T>)>).

Explicit Interface Implementations

Name | Description
ICollection..::.CopyTo | Copies the elements of the ICollection to an Array, starting at a particular Array index.
IEnumerable..::.GetEnumerator | Returns an enumerator that iterates through the ConcurrentBag<(Of <(T>)>).
IProducerConsumerCollection<(Of <(T>)>)..::.TryAdd | Attempts to add an object to the ConcurrentBag<(Of <(T>)>).

See Also

ConcurrentBag<(Of <(T>)>) Class
System.Collections.Concurrent Namespace


ICollection.CopyTo Method

[image]

.NET Framework Class Library
ConcurrentBag<(Of <(T>)>)..::.ICollection..::.CopyTo Method
ConcurrentBag<(Of <(T>)>) Class See Also Send Feedback

Copies the elements of the ICollection to an Array, starting at a particular Array index.

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

Syntax

Visual Basic (Declaration)
Private Sub CopyTo ( _
    array As Array, _
    index As Integer _
) Implements ICollection.CopyTo
C#
void ICollection.CopyTo(
    Array array,
    int index
)

Parameters

array
Type: System..::.Array
The one-dimensional Array that is the destination of the elements copied from the ConcurrentBag<(Of <(T>)>). The Array must have zero-based indexing.
index
Type: System..::.Int32
The zero-based index in array at which copying begins.

Implements

ICollection..::.CopyTo(Array, Int32)

Exceptions

Exception | Condition
System..::.ArgumentNullException | array is a null reference (Nothing in Visual Basic).
System..::.ArgumentOutOfRangeException | index is less than zero.
System..::.ArgumentException | array is multidimensional. -or- array does not have zero-based indexing. -or- index is equal to or greater than the length of the array -or- The number of elements in the source ICollection is greater than the available space from index to the end of the destination array. -or- The type of the source ICollection cannot be cast automatically to the type of the destination array.

See Also

ConcurrentBag<(Of <(T>)>) Class
System.Collections.Concurrent Namespace


IEnumerable.GetEnumerator Method

[image]

.NET Framework Class Library
ConcurrentBag<(Of <(T>)>)..::.IEnumerable..::.GetEnumerator Method
ConcurrentBag<(Of <(T>)>) Class See Also Send Feedback

Returns an enumerator that iterates through the ConcurrentBag<(Of <(T>)>).

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

Syntax

Visual Basic (Declaration)
Private Function GetEnumerator As IEnumerator
    Implements IEnumerable.GetEnumerator
C#
IEnumerator IEnumerable.GetEnumerator()

Return Value

An enumerator for the contents of the ConcurrentBag<(Of <(T>)>).

Implements

IEnumerable..::.GetEnumerator()()()

Remarks

The items enumerated represent a moment-in-time snapshot of the contents of the bag. It does not reflect any update to the collection after GetEnumerator()()() was called.

See Also

ConcurrentBag<(Of <(T>)>) Class
System.Collections.Concurrent Namespace


Add Method

[image]

.NET Framework Class Library
ConcurrentBag<(Of <(T>)>)..::.Add Method
ConcurrentBag<(Of <(T>)>) Class See Also Send Feedback

Adds an object to the ConcurrentBag<(Of <(T>)>).

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

Syntax

Visual Basic (Declaration)
Public Sub Add ( _
    item As T _
)
C#
public void Add(
    T item
)

Parameters

item
Type: T
The object to be added to the ConcurrentBag<(Of <(T>)>). The value can be a null reference (Nothing in Visual Basic) for reference types.

See Also

ConcurrentBag<(Of <(T>)>) Class
System.Collections.Concurrent Namespace


CopyTo Method

[image]

.NET Framework Class Library
ConcurrentBag<(Of <(T>)>)..::.CopyTo Method
ConcurrentBag<(Of <(T>)>) Class See Also Send Feedback

Copies the ConcurrentBag<(Of <(T>)>) elements to an existing one-dimensional Array, starting at the specified array index.

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

Syntax

Visual Basic (Declaration)
Public Sub CopyTo ( _
    array As T(), _
    index As Integer _
)
C#
public void CopyTo(
    T[] array,
    int index
)

Parameters

array
Type: array< T >[]()[]
The one-dimensional Array that is the destination of the elements copied from the ConcurrentBag<(Of <(T>)>). The Array must have zero-based indexing.
index
Type: System..::.Int32
The zero-based index in array at which copying begins.

Implements

IProducerConsumerCollection<(Of <(T>)>)..::.CopyTo(array<T>[]()[], Int32)

Exceptions

Exception | Condition
System..::.ArgumentNullException | array is a null reference (Nothing in Visual Basic).
System..::.ArgumentOutOfRangeException | index is less than zero.
System..::.ArgumentException | index is equal to or greater than the length of the array -or- the number of elements in the source ConcurrentBag<(Of <(T>)>) is greater than the available space from index to the end of the destination array.

See Also

ConcurrentBag<(Of <(T>)>) Class
System.Collections.Concurrent Namespace


GetEnumerator Method

[image]

.NET Framework Class Library
ConcurrentBag<(Of <(T>)>)..::.GetEnumerator Method
ConcurrentBag<(Of <(T>)>) Class See Also Send Feedback

Returns an enumerator that iterates through the ConcurrentBag<(Of <(T>)>).

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

Syntax

Visual Basic (Declaration)
Public Function GetEnumerator As IEnumerator(Of T)
C#
public IEnumerator<T> GetEnumerator()

Return Value

An enumerator for the contents of the ConcurrentBag<(Of <(T>)>).

Remarks

The enumeration represents a moment-in-time snapshot of the contents of the bag. It does not reflect any updates to the collection after GetEnumerator()()() was called. The enumerator is safe to use concurrently with reads from and writes to the bag.

See Also

ConcurrentBag<(Of <(T>)>) Class
System.Collections.Concurrent Namespace


IProducerConsumerCollection(T).TryAdd Method

[image]

.NET Framework Class Library
ConcurrentBag<(Of <(T>)>)..::.IProducerConsumerCollection<(Of <(T>)>)..::.TryAdd Method
ConcurrentBag<(Of <(T>)>) Class See Also Send Feedback

Attempts to add an object to the ConcurrentBag<(Of <(T>)>).

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

Syntax

Visual Basic (Declaration)
Private Function TryAdd ( _
    item As T _
) As Boolean Implements IProducerConsumerCollection(Of T).TryAdd
C#
bool IProducerConsumerCollection<T>.TryAdd(
    T item
)

Parameters

item
Type: T
The object to be added to the ConcurrentBag<(Of <(T>)>). The value can be a null reference (Nothing in Visual Basic) for reference types.

Return Value

Always returns true

Implements

IProducerConsumerCollection<(Of <(T>)>)..::.TryAdd(T)

See Also

ConcurrentBag<(Of <(T>)>) Class
System.Collections.Concurrent Namespace


ToArray Method

[image]

.NET Framework Class Library
ConcurrentBag<(Of <(T>)>)..::.ToArray Method
ConcurrentBag<(Of <(T>)>) Class See Also Send Feedback

Copies the ConcurrentBag<(Of <(T>)>) elements to a new array.

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

Syntax

Visual Basic (Declaration)
Public Function ToArray As T()
C#
public T[] ToArray()

Return Value

A new array containing a snapshot of elements copied from the ConcurrentBag<(Of <(T>)>).

See Also

ConcurrentBag<(Of <(T>)>) Class
System.Collections.Concurrent Namespace


TryPeek Method

[image]

.NET Framework Class Library
ConcurrentBag<(Of <(T>)>)..::.TryPeek Method
ConcurrentBag<(Of <(T>)>) Class See Also Send Feedback

Attempts to return an object from the ConcurrentBag<(Of <(T>)>) without removing it.

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

Syntax

Visual Basic (Declaration)
Public Function TryPeek ( _
    <OutAttribute> ByRef result As T _
) As Boolean
C#
public bool TryPeek(
    out T result
)

Parameters

result
Type: T %
When this method returns, result contains an object from the ConcurrentBag<(Of <(T>)>) or the default value of T if the operation failed.

Return Value

true if and object was returned successfully; otherwise, false.

See Also

ConcurrentBag<(Of <(T>)>) Class
System.Collections.Concurrent Namespace


TryTake Method

[image]

.NET Framework Class Library
ConcurrentBag<(Of <(T>)>)..::.TryTake Method
ConcurrentBag<(Of <(T>)>) Class See Also Send Feedback

Attempts to remove and return an object from the ConcurrentBag<(Of <(T>)>).

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

Syntax

Visual Basic (Declaration)
Public Function TryTake ( _
    <OutAttribute> ByRef result As T _
) As Boolean
C#
public bool TryTake(
    out T result
)

Parameters

result
Type: T %
When this method returns, result contains the object removed from the ConcurrentBag<(Of <(T>)>) or the default value of T if the operation failed.

Return Value

true if an object was removed successfully; otherwise, false.

Implements

IProducerConsumerCollection<(Of <(T>)>)..::.TryTake(T%)

See Also

ConcurrentBag<(Of <(T>)>) Class
System.Collections.Concurrent Namespace


ConcurrentBag(T) Properties

[image] [image]

.NET Framework Class Library
ConcurrentBag<(Of <(T>)>) Properties
ConcurrentBag<(Of <(T>)>) Class See Also Send Feedback

The ConcurrentBag<(Of <(T>)>) type exposes the following members.

Properties

Name | Description
Count | Gets the number of elements contained in the ConcurrentBag<(Of <(T>)>).
IsEmpty | Gets a value that indicates whether the ConcurrentBag<(Of <(T>)>) is empty.

Explicit Interface Implementations

Name | Description
ICollection..::.IsSynchronized | Gets a value indicating whether access to the ICollection is synchronized with the SyncRoot.
ICollection..::.SyncRoot | Gets an object that can be used to synchronize access to the ICollection. This property is not supported.

See Also

ConcurrentBag<(Of <(T>)>) Class
System.Collections.Concurrent Namespace


ICollection.IsSynchronized Property

[image]

.NET Framework Class Library
ConcurrentBag<(Of <(T>)>)..::.ICollection..::.IsSynchronized Property
ConcurrentBag<(Of <(T>)>) Class See Also Send Feedback

Gets a value indicating whether access to the ICollection is synchronized with the SyncRoot.

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

Syntax

Visual Basic (Declaration)
Private ReadOnly Property IsSynchronized As Boolean
    Implements ICollection.IsSynchronized
C#
bool ICollection.IsSynchronized { get; }

Field Value

true if access to the ICollection is synchronized with the SyncRoot; otherwise, false. For ConcurrentBag<(Of <(T>)>), this property always returns false.

Implements

ICollection..::.IsSynchronized

See Also

ConcurrentBag<(Of <(T>)>) Class
System.Collections.Concurrent Namespace


ICollection.SyncRoot Property

[image]

.NET Framework Class Library
ConcurrentBag<(Of <(T>)>)..::.ICollection..::.SyncRoot Property
ConcurrentBag<(Of <(T>)>) Class See Also Send Feedback

Gets an object that can be used to synchronize access to the ICollection. This property is not supported.

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

Syntax

Visual Basic (Declaration)
Private ReadOnly Property SyncRoot As Object
    Implements ICollection.SyncRoot
C#
Object ICollection.SyncRoot { get; }

Implements

ICollection..::.SyncRoot

Exceptions

Exception | Condition
System..::.NotSupportedException | The SyncRoot property is not supported.

See Also

ConcurrentBag<(Of <(T>)>) Class
System.Collections.Concurrent Namespace


Count Property

[image]

.NET Framework Class Library
ConcurrentBag<(Of <(T>)>)..::.Count Property
ConcurrentBag<(Of <(T>)>) Class See Also Send Feedback

Gets the number of elements contained in the ConcurrentBag<(Of <(T>)>).

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

Syntax

Visual Basic (Declaration)
Public ReadOnly Property Count As Integer
C#
public int Count { get; }

Field Value

The number of elements contained in the ConcurrentBag<(Of <(T>)>).

Implements

ICollection..::.Count

Remarks

The count returned represents a moment-in-time snapshot of the contents of the bag. It does not reflect any updates to the collection after GetEnumerator()()() was called.

See Also

ConcurrentBag<(Of <(T>)>) Class
System.Collections.Concurrent Namespace


IsEmpty Property

[image]

.NET Framework Class Library
ConcurrentBag<(Of <(T>)>)..::.IsEmpty Property
ConcurrentBag<(Of <(T>)>) Class See Also Send Feedback

Gets a value that indicates whether the ConcurrentBag<(Of <(T>)>) is empty.

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

Syntax

Visual Basic (Declaration)
Public ReadOnly Property IsEmpty As Boolean
C#
public bool IsEmpty { get; }

Field Value

true if the ConcurrentBag<(Of <(T>)>) is empty; otherwise, false.

See Also

ConcurrentBag<(Of <(T>)>) Class
System.Collections.Concurrent Namespace


ConcurrentDictionary(TKey, TValue) Class

[image]

.NET Framework Class Library
ConcurrentDictionary<(Of <(TKey, TValue>)>) Class
See Also Send Feedback

Represents a thread-safe collection of keys and values.

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

Syntax

Visual Basic (Declaration)
<SerializableAttribute> _
<ComVisibleAttribute(False)> _
<HostProtectionAttribute(SecurityAction.LinkDemand, Synchronization := True,  _
    ExternalThreading := True)> _
Public Class ConcurrentDictionary(Of TKey, TValue) _
    Implements IDictionary(Of TKey, TValue), ICollection(Of KeyValuePair(Of TKey, TValue)),  _
    IEnumerable(Of KeyValuePair(Of TKey, TValue)), IDictionary,  _
    ICollection, IEnumerable
C#
[SerializableAttribute]
[ComVisibleAttribute(false)]
[HostProtectionAttribute(SecurityAction.LinkDemand, Synchronization = true,
    ExternalThreading = true)]
public class ConcurrentDictionary<TKey, TValue> : IDictionary<TKey, TValue>,
    ICollection<KeyValuePair<TKey, TValue>>, IEnumerable<KeyValuePair<TKey, TValue>>,
    IDictionary, ICollection, IEnumerable

Type Parameters

TKey
The type of the keys in the dictionary.
TValue
The type of the values in the dictionary.

Remarks

All public and protected members of ConcurrentDictionary<(Of <(TKey, TValue>)>) are thread-safe and may be used concurrently from multiple threads.

Inheritance Hierarchy

System..::.Object
System.Collections.Concurrent..::.ConcurrentDictionary<(Of <(TKey, TValue>)>)

See Also

System.Collections.Concurrent Namespace


ConcurrentDictionary(TKey, TValue) Constructor

[image] [image]

.NET Framework Class Library
ConcurrentDictionary<(Of <(TKey, TValue>)>) Constructor
ConcurrentDictionary<(Of <(TKey, TValue>)>) Class See Also Send Feedback

Overload List

Name | Description
ConcurrentDictionary<(Of <(TKey, TValue>)>)()()() | Initializes a new instance of the ConcurrentDictionary<(Of <(TKey, TValue>)>) class that is empty, has the default concurrency level, has the default initial capacity, and uses the default comparer for the key type.
ConcurrentDictionary<(Of <(TKey, TValue>)>)(IEnumerable<(Of <(KeyValuePair<(Of <(TKey, TValue>)>)>)>)) | Initializes a new instance of the ConcurrentDictionary<(Of <(TKey, TValue>)>) class that contains elements copied from the specified IEnumerable<(Of <(KeyValuePair<(Of <(TKey, TValue>)>)>)>), has the default concurrency level, has the default initial capacity, and uses the default comparer for the key type.
ConcurrentDictionary<(Of <(TKey, TValue>)>)(IEqualityComparer<(Of <(TKey>)>)) | Initializes a new instance of the ConcurrentDictionary<(Of <(TKey, TValue>)>) class that is empty, has the specified concurrency level and capacity, and uses the specified IEqualityComparer<(Of <(TKey>)>).
ConcurrentDictionary<(Of <(TKey, TValue>)>)(IEnumerable<(Of <(KeyValuePair<(Of <(TKey, TValue>)>)>)>), IEqualityComparer<(Of <(TKey>)>)) | Initializes a new instance of the ConcurrentDictionary<(Of <(TKey, TValue>)>) class that contains elements copied from the specified IEnumerable, has the default concurrency level, has the default initial capacity, and uses the specified IEqualityComparer<(Of <(TKey>)>).
ConcurrentDictionary<(Of <(TKey, TValue>)>)(Int32, Int32) | Initializes a new instance of the ConcurrentDictionary<(Of <(TKey, TValue>)>) class that is empty, has the specified concurrency level and capacity, and uses the default comparer for the key type.
ConcurrentDictionary<(Of <(TKey, TValue>)>)(Int32, IEnumerable<(Of <(KeyValuePair<(Of <(TKey, TValue>)>)>)>), IEqualityComparer<(Of <(TKey>)>)) | Initializes a new instance of the ConcurrentDictionary<(Of <(TKey, TValue>)>) class that contains elements copied from the specified IEnumerable, has the specified concurrency level, has the specified initial capacity, and uses the specified IEqualityComparer<(Of <(TKey>)>).
ConcurrentDictionary<(Of <(TKey, TValue>)>)(Int32, Int32, IEqualityComparer<(Of <(TKey>)>)) | Initializes a new instance of the ConcurrentDictionary<(Of <(TKey, TValue>)>) class that is empty, has the specified concurrency level, has the specified initial capacity, and uses the specified IEqualityComparer<(Of <(TKey>)>).

See Also

ConcurrentDictionary<(Of <(TKey, TValue>)>) Class
System.Collections.Concurrent Namespace


ConcurrentDictionary(TKey, TValue) Constructor

[image]

.NET Framework Class Library
ConcurrentDictionary<(Of <(TKey, TValue>)>) Constructor
ConcurrentDictionary<(Of <(TKey, TValue>)>) Class See Also Send Feedback

Initializes a new instance of the ConcurrentDictionary<(Of <(TKey, TValue>)>) class that is empty, has the default concurrency level, has the default initial capacity, and uses the default comparer for the key type.

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

Syntax

Visual Basic (Declaration)
Public Sub New
C#
public ConcurrentDictionary()

See Also

ConcurrentDictionary<(Of <(TKey, TValue>)>) Class
ConcurrentDictionary<(Of <(TKey, TValue>)>) Overload
System.Collections.Concurrent Namespace


ConcurrentDictionary(TKey, TValue) Constructor (IEnumerable(KeyValuePair(TKey, TValue)))

[image]

.NET Framework Class Library
ConcurrentDictionary<(Of <(TKey, TValue>)>) Constructor (IEnumerable<(Of <(KeyValuePair<(Of <(TKey, TValue>)>)>)>))
ConcurrentDictionary<(Of <(TKey, TValue>)>) Class See Also Send Feedback

Initializes a new instance of the ConcurrentDictionary<(Of <(TKey, TValue>)>) class that contains elements copied from the specified IEnumerable<(Of <(KeyValuePair<(Of <(TKey, TValue>)>)>)>), has the default concurrency level, has the default initial capacity, and uses the default comparer for the key type.

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

Syntax

Visual Basic (Declaration)
Public Sub New ( _
    collection As IEnumerable(Of KeyValuePair(Of TKey, TValue)) _
)
C#
public ConcurrentDictionary(
    IEnumerable<KeyValuePair<TKey, TValue>> collection
)

Parameters

collection
Type: System.Collections.Generic..::.IEnumerable<(Of <(KeyValuePair<(Of <( TKey, TValue >)>)>)>)
The IEnumerable<(Of <(KeyValuePair<(Of <(TKey, TValue>)>)>)>) whose elements are copied to the new ConcurrentDictionary<(Of <(TKey, TValue>)>).

Exceptions

Exception | Condition
System..::.ArgumentNullException | collection is a null reference (Nothing in Visual Basic).
System..::.ArgumentException | collection contains one or more duplicate keys.

See Also

ConcurrentDictionary<(Of <(TKey, TValue>)>) Class
ConcurrentDictionary<(Of <(TKey, TValue>)>) Overload
System.Collections.Concurrent Namespace


ConcurrentDictionary(TKey, TValue) Constructor (IEqualityComparer(TKey))

[image]

.NET Framework Class Library
ConcurrentDictionary<(Of <(TKey, TValue>)>) Constructor (IEqualityComparer<(Of <(TKey>)>))
ConcurrentDictionary<(Of <(TKey, TValue>)>) Class See Also Send Feedback

Initializes a new instance of the ConcurrentDictionary<(Of <(TKey, TValue>)>) class that is empty, has the specified concurrency level and capacity, and uses the specified IEqualityComparer<(Of <(TKey>)>).

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

Syntax

Visual Basic (Declaration)
Public Sub New ( _
    comparer As IEqualityComparer(Of TKey) _
)
C#
public ConcurrentDictionary(
    IEqualityComparer<TKey> comparer
)

Parameters

comparer
Type: System.Collections.Generic..::.IEqualityComparer<(Of <( TKey >)>)
The IEqualityComparer<(Of <(TKey>)>) implementation to use when comparing keys.

Exceptions

Exception | Condition
System..::.ArgumentNullException | comparer is a null reference (Nothing in Visual Basic).

See Also

ConcurrentDictionary<(Of <(TKey, TValue>)>) Class
ConcurrentDictionary<(Of <(TKey, TValue>)>) Overload
System.Collections.Concurrent Namespace


ConcurrentDictionary(TKey, TValue) Constructor (IEnumerable(KeyValuePair(TKey, TValue)), IEqualityComparer(TKey))

[image]

.NET Framework Class Library
ConcurrentDictionary<(Of <(TKey, TValue>)>) Constructor (IEnumerable<(Of <(KeyValuePair<(Of <(TKey, TValue>)>)>)>), IEqualityComparer<(Of <(TKey>)>))
ConcurrentDictionary<(Of <(TKey, TValue>)>) Class See Also Send Feedback

Initializes a new instance of the ConcurrentDictionary<(Of <(TKey, TValue>)>) class that contains elements copied from the specified IEnumerable, has the default concurrency level, has the default initial capacity, and uses the specified IEqualityComparer<(Of <(TKey>)>).

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

Syntax

Visual Basic (Declaration)
Public Sub New ( _
    collection As IEnumerable(Of KeyValuePair(Of TKey, TValue)), _
    comparer As IEqualityComparer(Of TKey) _
)
C#
public ConcurrentDictionary(
    IEnumerable<KeyValuePair<TKey, TValue>> collection,
    IEqualityComparer<TKey> comparer
)

Parameters

collection
Type: System.Collections.Generic..::.IEnumerable<(Of <(KeyValuePair<(Of <( TKey, TValue >)>)>)>)
The IEnumerable<(Of <(KeyValuePair<(Of <(TKey, TValue>)>)>)>) whose elements are copied to the new ConcurrentDictionary<(Of <(TKey, TValue>)>).
comparer
Type: System.Collections.Generic..::.IEqualityComparer<(Of <( TKey >)>)
The IEqualityComparer<(Of <(TKey>)>) implementation to use when comparing keys.

Exceptions

Exception | Condition
System..::.ArgumentNullException | collection is a null reference (Nothing in Visual Basic). -or- comparer is a null reference (Nothing in Visual Basic).

See Also

ConcurrentDictionary<(Of <(TKey, TValue>)>) Class
ConcurrentDictionary<(Of <(TKey, TValue>)>) Overload
System.Collections.Concurrent Namespace


ConcurrentDictionary(TKey, TValue) Constructor (Int32, Int32)

[image]

.NET Framework Class Library
ConcurrentDictionary<(Of <(TKey, TValue>)>) Constructor (Int32, Int32)
ConcurrentDictionary<(Of <(TKey, TValue>)>) Class See Also Send Feedback

Initializes a new instance of the ConcurrentDictionary<(Of <(TKey, TValue>)>) class that is empty, has the specified concurrency level and capacity, and uses the default comparer for the key type.

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

Syntax

Visual Basic (Declaration)
Public Sub New ( _
    concurrencyLevel As Integer, _
    capacity As Integer _
)
C#
public ConcurrentDictionary(
    int concurrencyLevel,
    int capacity
)

Parameters

concurrencyLevel
Type: System..::.Int32
The estimated number of threads that will update the ConcurrentDictionary<(Of <(TKey, TValue>)>) concurrently.
capacity
Type: System..::.Int32
The initial number of elements that the ConcurrentDictionary<(Of <(TKey, TValue>)>) can contain.

Exceptions

Exception | Condition
System..::.ArgumentOutOfRangeException | concurrencyLevel is less than 1.
System..::.ArgumentOutOfRangeException | capacity is less than 0.

See Also

ConcurrentDictionary<(Of <(TKey, TValue>)>) Class
ConcurrentDictionary<(Of <(TKey, TValue>)>) Overload
System.Collections.Concurrent Namespace


ConcurrentDictionary(TKey, TValue) Constructor (Int32, IEnumerable(KeyValuePair(TKey, TValue)), IEqualityComparer(TKey))

[image]

.NET Framework Class Library
ConcurrentDictionary<(Of <(TKey, TValue>)>) Constructor (Int32, IEnumerable<(Of <(KeyValuePair<(Of <(TKey, TValue>)>)>)>), IEqualityComparer<(Of <(TKey>)>))
ConcurrentDictionary<(Of <(TKey, TValue>)>) Class See Also Send Feedback

Initializes a new instance of the ConcurrentDictionary<(Of <(TKey, TValue>)>) class that contains elements copied from the specified IEnumerable, has the specified concurrency level, has the specified initial capacity, and uses the specified IEqualityComparer<(Of <(TKey>)>).

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

Syntax

Visual Basic (Declaration)
Public Sub New ( _
    concurrencyLevel As Integer, _
    collection As IEnumerable(Of KeyValuePair(Of TKey, TValue)), _
    comparer As IEqualityComparer(Of TKey) _
)
C#
public ConcurrentDictionary(
    int concurrencyLevel,
    IEnumerable<KeyValuePair<TKey, TValue>> collection,
    IEqualityComparer<TKey> comparer
)

Parameters

concurrencyLevel
Type: System..::.Int32
The estimated number of threads that will update the ConcurrentDictionary<(Of <(TKey, TValue>)>) concurrently.
collection
Type: System.Collections.Generic..::.IEnumerable<(Of <(KeyValuePair<(Of <( TKey, TValue >)>)>)>)
The IEnumerable<(Of <(KeyValuePair<(Of <(TKey, TValue>)>)>)>) whose elements are copied to the new ConcurrentDictionary<(Of <(TKey, TValue>)>).
comparer
Type: System.Collections.Generic..::.IEqualityComparer<(Of <( TKey >)>)
The IEqualityComparer<(Of <(TKey>)>) implementation to use when comparing keys.

Exceptions

Exception | Condition
System..::.ArgumentNullException | collection is a null reference (Nothing in Visual Basic). -or- comparer is a null reference (Nothing in Visual Basic).
System..::.ArgumentOutOfRangeException | concurrencyLevel is less than 1.
System..::.ArgumentException | collection contains one or more duplicate keys.

See Also

ConcurrentDictionary<(Of <(TKey, TValue>)>) Class
ConcurrentDictionary<(Of <(TKey, TValue>)>) Overload
System.Collections.Concurrent Namespace


ConcurrentDictionary(TKey, TValue) Constructor (Int32, Int32, IEqualityComparer(TKey))

[image]

.NET Framework Class Library
ConcurrentDictionary<(Of <(TKey, TValue>)>) Constructor (Int32, Int32, IEqualityComparer<(Of <(TKey>)>))
ConcurrentDictionary<(Of <(TKey, TValue>)>) Class See Also Send Feedback

Initializes a new instance of the ConcurrentDictionary<(Of <(TKey, TValue>)>) class that is empty, has the specified concurrency level, has the specified initial capacity, and uses the specified IEqualityComparer<(Of <(TKey>)>).

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

Syntax

Visual Basic (Declaration)
Public Sub New ( _
    concurrencyLevel As Integer, _
    capacity As Integer, _
    comparer As IEqualityComparer(Of TKey) _
)
C#
public ConcurrentDictionary(
    int concurrencyLevel,
    int capacity,
    IEqualityComparer<TKey> comparer
)

Parameters

concurrencyLevel
Type: System..::.Int32
The estimated number of threads that will update the ConcurrentDictionary<(Of <(TKey, TValue>)>) concurrently.
capacity
Type: System..::.Int32
The initial number of elements that the ConcurrentDictionary<(Of <(TKey, TValue>)>) can contain.
comparer
Type: System.Collections.Generic..::.IEqualityComparer<(Of <( TKey >)>)
The IEqualityComparer<(Of <(TKey>)>) implementation to use when comparing keys.

Exceptions

Exception | Condition
System..::.ArgumentOutOfRangeException | concurrencyLevel is less than 1. -or- capacity is less than 0.
System..::.ArgumentNullException | comparer is a null reference (Nothing in Visual Basic).

See Also

ConcurrentDictionary<(Of <(TKey, TValue>)>) Class
ConcurrentDictionary<(Of <(TKey, TValue>)>) Overload
System.Collections.Concurrent Namespace


ConcurrentDictionary(TKey, TValue) Methods

[image] [image]

.NET Framework Class Library
ConcurrentDictionary<(Of <(TKey, TValue>)>) Methods
ConcurrentDictionary<(Of <(TKey, TValue>)>) Class See Also Send Feedback

The ConcurrentDictionary<(Of <(TKey, TValue>)>) type exposes the following members.

Methods

Name | Description
AddOrUpdate | Overloaded.
Clear | Removes all keys and values from the ConcurrentDictionary<(Of <(TKey, TValue>)>).
ContainsKey | Determines whether the ConcurrentDictionary<(Of <(TKey, TValue>)>) contains the specified key.
Equals | (Inherited from Object.)
Finalize | (Inherited from Object.)
GetEnumerator | Returns an enumerator that iterates through the ConcurrentDictionary<(Of <(TKey, TValue>)>).
GetHashCode | (Inherited from Object.)
GetOrAdd | Overloaded.
GetType | (Inherited from Object.)
MemberwiseClone | (Inherited from Object.)
ToArray | Copies the key and value pairs stored in the ConcurrentDictionary<(Of <(TKey, TValue>)>) to a new array.
ToString | (Inherited from Object.)
TryAdd | Attempts to add the specified key and value to the ConcurrentDictionary<(Of <(TKey, TValue>)>).
TryGetValue | Attempts to get the value associated with the specified key from the ConcurrentDictionary<(Of <(TKey, TValue>)>).
TryRemove | Attempts to remove and return the the value with the specified key from the ConcurrentDictionary<(Of <(TKey, TValue>)>).
TryUpdate | Compares the existing value for the specified key with a specified value, and if they’re equal, updates the key with a third value.

Explicit Interface Implementations

Name | Description
ICollection<(Of <(KeyValuePair<(Of <(TKey, TValue>)>)>)>)..::.Add |
IDictionary<(Of <(TKey, TValue>)>)..::.Add | Adds the specified key and value to the IDictionary<(Of <(TKey, TValue>)>).
IDictionary..::.Add | Adds the specified key and value to the dictionary.
ICollection<(Of <(KeyValuePair<(Of <(TKey, TValue>)>)>)>)..::.Contains |
IDictionary..::.Contains | Gets whether the IDictionary<(Of <(TKey, TValue>)>) contains an element with the specified key.
ICollection<(Of <(KeyValuePair<(Of <(TKey, TValue>)>)>)>)..::.CopyTo |
ICollection..::.CopyTo | Copies the elements of the ICollection to an array, starting at the specified array index.
IDictionary..::.GetEnumerator | Provides an IDictionaryEnumerator for the IDictionary<(Of <(TKey, TValue>)>).
IEnumerable..::.GetEnumerator | Returns an enumerator that iterates through the ConcurrentDictionary<(Of <(TKey, TValue>)>).
ICollection<(Of <(KeyValuePair<(Of <(TKey, TValue>)>)>)>)..::.Remove |
IDictionary<(Of <(TKey, TValue>)>)..::.Remove | Removes the element with the specified key from the IDictionary<(Of <(TKey, TValue>)>).
IDictionary..::.Remove | Removes the element with the specified key from the IDictionary.

See Also

ConcurrentDictionary<(Of <(TKey, TValue>)>) Class
System.Collections.Concurrent Namespace


ICollection(KeyValuePair(TKey, TValue)).Add Method

[image]

.NET Framework Class Library
ConcurrentDictionary<(Of <(TKey, TValue>)>)..::.ICollection<(Of <(KeyValuePair<(Of <(TKey, TValue>)>)>)>)..::.Add Method
ConcurrentDictionary<(Of <(TKey, TValue>)>) Class See Also Send Feedback

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

Syntax

Visual Basic (Declaration)
Private Sub Add ( _
    keyValuePair As KeyValuePair(Of TKey, TValue) _
) Implements ICollection(Of KeyValuePair(Of TKey, TValue)).Add
C#
void ICollection<KeyValuePair<TKey, TValue>>.Add(
    KeyValuePair<TKey, TValue> keyValuePair
)

Parameters

keyValuePair
Type: System.Collections.Generic..::.KeyValuePair<(Of <( TKey, TValue >)>)

Implements

ICollection<(Of <(T>)>)..::.Add(T)

See Also

ConcurrentDictionary<(Of <(TKey, TValue>)>) Class
System.Collections.Concurrent Namespace


IDictionary(TKey, TValue).Add Method

[image]

.NET Framework Class Library
ConcurrentDictionary<(Of <(TKey, TValue>)>)..::.IDictionary<(Of <(TKey, TValue>)>)..::.Add Method
ConcurrentDictionary<(Of <(TKey, TValue>)>) Class See Also Send Feedback

Adds the specified key and value to the IDictionary<(Of <(TKey, TValue>)>).

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

Syntax

Visual Basic (Declaration)
Private Sub Add ( _
    key As TKey, _
    value As TValue _
) Implements IDictionary(Of TKey, TValue).Add
C#
void IDictionary<TKey, TValue>.Add(
    TKey key,
    TValue value
)

Parameters

key
Type: TKey
The object to use as the key of the element to add.
value
Type: TValue
The object to use as the value of the element to add.

Implements

IDictionary<(Of <(TKey, TValue>)>)..::.Add(TKey, TValue)

Exceptions

Exception | Condition
System..::.ArgumentNullException | key is a null reference (Nothing in Visual Basic).
System..::.OverflowException | The dictionary contains too many elements.
System..::.ArgumentException | An element with the same key already exists in the ConcurrentDictionary<(Of <(TKey, TValue>)>).

See Also

ConcurrentDictionary<(Of <(TKey, TValue>)>) Class
System.Collections.Concurrent Namespace


IDictionary.Add Method

[image]

.NET Framework Class Library
ConcurrentDictionary<(Of <(TKey, TValue>)>)..::.IDictionary..::.Add Method
ConcurrentDictionary<(Of <(TKey, TValue>)>) Class See Also Send Feedback

Adds the specified key and value to the dictionary.

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

Syntax

Visual Basic (Declaration)
Private Sub Add ( _
    key As Object, _
    value As Object _
) Implements IDictionary.Add
C#
void IDictionary.Add(
    Object key,
    Object value
)

Parameters

key
Type: System..::.Object
The object to use as the key.
value
Type: System..::.Object
The object to use as the value.

Implements

IDictionary..::.Add(Object, Object)

Exceptions

Exception | Condition
System..::.ArgumentNullException | key is a null reference (Nothing in Visual Basic).
System..::.OverflowException | The dictionary contains too many elements.
System..::.ArgumentException | key is of a type that is not assignable to the key type TKey of the Dictionary<(Of <(TKey, TValue>)>). -or- value is of a type that is not assignable to TValue, the type of values in the Dictionary<(Of <(TKey, TValue>)>). -or- A value with the same key already exists in the Dictionary<(Of <(TKey, TValue>)>).

See Also

ConcurrentDictionary<(Of <(TKey, TValue>)>) Class
System.Collections.Concurrent Namespace


ICollection(KeyValuePair(TKey, TValue)).Contains Method

[image]

.NET Framework Class Library
ConcurrentDictionary<(Of <(TKey, TValue>)>)..::.ICollection<(Of <(KeyValuePair<(Of <(TKey, TValue>)>)>)>)..::.Contains Method
ConcurrentDictionary<(Of <(TKey, TValue>)>) Class See Also Send Feedback

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

Syntax

Visual Basic (Declaration)
Private Function Contains ( _
    keyValuePair As KeyValuePair(Of TKey, TValue) _
) As Boolean Implements ICollection(Of KeyValuePair(Of TKey, TValue)).Contains
C#
bool ICollection<KeyValuePair<TKey, TValue>>.Contains(
    KeyValuePair<TKey, TValue> keyValuePair
)

Parameters

keyValuePair
Type: System.Collections.Generic..::.KeyValuePair<(Of <( TKey, TValue >)>)

Implements

ICollection<(Of <(T>)>)..::.Contains(T)

See Also

ConcurrentDictionary<(Of <(TKey, TValue>)>) Class
System.Collections.Concurrent Namespace


IDictionary.Contains Method

[image]

.NET Framework Class Library
ConcurrentDictionary<(Of <(TKey, TValue>)>)..::.IDictionary..::.Contains Method
ConcurrentDictionary<(Of <(TKey, TValue>)>) Class See Also Send Feedback

Gets whether the IDictionary<(Of <(TKey, TValue>)>) contains an element with the specified key.

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

Syntax

Visual Basic (Declaration)
Private Function Contains ( _
    key As Object _
) As Boolean Implements IDictionary.Contains
C#
bool IDictionary.Contains(
    Object key
)

Parameters

key
Type: System..::.Object
The key to locate in the IDictionary<(Of <(TKey, TValue>)>).

Return Value

true if the IDictionary<(Of <(TKey, TValue>)>) contains an element with the specified key; otherwise, false.

Implements

IDictionary..::.Contains(Object)

Exceptions

Exception | Condition
System..::.ArgumentNullException | key is a null reference (Nothing in Visual Basic).

See Also

ConcurrentDictionary<(Of <(TKey, TValue>)>) Class
System.Collections.Concurrent Namespace


ICollection(KeyValuePair(TKey, TValue)).CopyTo Method

[image]

.NET Framework Class Library
ConcurrentDictionary<(Of <(TKey, TValue>)>)..::.ICollection<(Of <(KeyValuePair<(Of <(TKey, TValue>)>)>)>)..::.CopyTo Method
ConcurrentDictionary<(Of <(TKey, TValue>)>) Class See Also Send Feedback

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

Syntax

Visual Basic (Declaration)
Private Sub CopyTo ( _
    array As KeyValuePair(Of TKey, TValue)(), _
    index As Integer _
) Implements ICollection(Of KeyValuePair(Of TKey, TValue)).CopyTo
C#
void ICollection<KeyValuePair<TKey, TValue>>.CopyTo(
    KeyValuePair<TKey, TValue>[] array,
    int index
)

Parameters

array
Type: array< System.Collections.Generic..::.KeyValuePair<(Of <( TKey, TValue >)>) >[]()[]
index
Type: System..::.Int32

Implements

ICollection<(Of <(T>)>)..::.CopyTo(array<T>[]()[], Int32)

See Also

ConcurrentDictionary<(Of <(TKey, TValue>)>) Class
System.Collections.Concurrent Namespace


ICollection.CopyTo Method

[image]

.NET Framework Class Library
ConcurrentDictionary<(Of <(TKey, TValue>)>)..::.ICollection..::.CopyTo Method
ConcurrentDictionary<(Of <(TKey, TValue>)>) Class See Also Send Feedback

Copies the elements of the ICollection to an array, starting at the specified array index.

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

Syntax

Visual Basic (Declaration)
Private Sub CopyTo ( _
    array As Array, _
    index As Integer _
) Implements ICollection.CopyTo
C#
void ICollection.CopyTo(
    Array array,
    int index
)

Parameters

array
Type: System..::.Array
The one-dimensional array that is the destination of the elements copied from the ICollection. The array must have zero-based indexing.
index
Type: System..::.Int32
The zero-based index in array at which copying begins.

Implements

ICollection..::.CopyTo(Array, Int32)

Exceptions

Exception | Condition
System..::.ArgumentNullException | array is a null reference (Nothing in Visual Basic).
System..::.ArgumentOutOfRangeException | index is less than 0.
System..::.ArgumentException | index is equal to or greater than the length of the array. -or- The number of elements in the source ICollection is greater than the available space from index to the end of the destination array.

See Also

ConcurrentDictionary<(Of <(TKey, TValue>)>) Class
System.Collections.Concurrent Namespace


IDictionary.GetEnumerator Method

[image]

.NET Framework Class Library
ConcurrentDictionary<(Of <(TKey, TValue>)>)..::.IDictionary..::.GetEnumerator Method
ConcurrentDictionary<(Of <(TKey, TValue>)>) Class See Also Send Feedback

Provides an IDictionaryEnumerator for the IDictionary<(Of <(TKey, TValue>)>).

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

Syntax

Visual Basic (Declaration)
Private Function GetEnumerator As IDictionaryEnumerator
    Implements IDictionary.GetEnumerator
C#
IDictionaryEnumerator IDictionary.GetEnumerator()

Return Value

An IDictionaryEnumerator for the IDictionary<(Of <(TKey, TValue>)>).

Implements

IDictionary..::.GetEnumerator()()()

See Also

ConcurrentDictionary<(Of <(TKey, TValue>)>) Class
System.Collections.Concurrent Namespace


IEnumerable.GetEnumerator Method

[image]

.NET Framework Class Library
ConcurrentDictionary<(Of <(TKey, TValue>)>)..::.IEnumerable..::.GetEnumerator Method
ConcurrentDictionary<(Of <(TKey, TValue>)>) Class See Also Send Feedback

Returns an enumerator that iterates through the ConcurrentDictionary<(Of <(TKey, TValue>)>).

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

Syntax

Visual Basic (Declaration)
Private Function GetEnumerator As IEnumerator
    Implements IEnumerable.GetEnumerator
C#
IEnumerator IEnumerable.GetEnumerator()

Return Value

An enumerator for the ConcurrentDictionary<(Of <(TKey, TValue>)>).

Implements

IEnumerable..::.GetEnumerator()()()

Remarks

The enumerator returned from the dictionary is safe to use concurrently with reads and writes to the dictionary, however it does not represent a moment-in-time snapshot of the dictionary. The contents exposed through the enumerator may contain modifications made to the dictionary after GetEnumerator()()() was called.

See Also

ConcurrentDictionary<(Of <(TKey, TValue>)>) Class
System.Collections.Concurrent Namespace


ICollection(KeyValuePair(TKey, TValue)).Remove Method

[image]

.NET Framework Class Library
ConcurrentDictionary<(Of <(TKey, TValue>)>)..::.ICollection<(Of <(KeyValuePair<(Of <(TKey, TValue>)>)>)>)..::.Remove Method
ConcurrentDictionary<(Of <(TKey, TValue>)>) Class See Also Send Feedback

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

Syntax

Visual Basic (Declaration)
Private Function Remove ( _
    keyValuePair As KeyValuePair(Of TKey, TValue) _
) As Boolean Implements ICollection(Of KeyValuePair(Of TKey, TValue)).Remove
C#
bool ICollection<KeyValuePair<TKey, TValue>>.Remove(
    KeyValuePair<TKey, TValue> keyValuePair
)

Parameters

keyValuePair
Type: System.Collections.Generic..::.KeyValuePair<(Of <( TKey, TValue >)>)

Implements

ICollection<(Of <(T>)>)..::.Remove(T)

See Also

ConcurrentDictionary<(Of <(TKey, TValue>)>) Class
System.Collections.Concurrent Namespace


IDictionary(TKey, TValue).Remove Method

[image]

.NET Framework Class Library
ConcurrentDictionary<(Of <(TKey, TValue>)>)..::.IDictionary<(Of <(TKey, TValue>)>)..::.Remove Method
ConcurrentDictionary<(Of <(TKey, TValue>)>) Class See Also Send Feedback

Removes the element with the specified key from the IDictionary<(Of <(TKey, TValue>)>).

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

Syntax

Visual Basic (Declaration)
Private Function Remove ( _
    key As TKey _
) As Boolean Implements IDictionary(Of TKey, TValue).Remove
C#
bool IDictionary<TKey, TValue>.Remove(
    TKey key
)

Parameters

key
Type: TKey
The key of the element to remove.

Return Value

true if the element is successfully remove; otherwise false. This method also returns false if key was not found in the original IDictionary<(Of <(TKey, TValue>)>).

Implements

IDictionary<(Of <(TKey, TValue>)>)..::.Remove(TKey)

Exceptions

Exception | Condition
System..::.ArgumentNullException | key is a null reference (Nothing in Visual Basic).

See Also

ConcurrentDictionary<(Of <(TKey, TValue>)>) Class
System.Collections.Concurrent Namespace


IDictionary.Remove Method

[image]

.NET Framework Class Library
ConcurrentDictionary<(Of <(TKey, TValue>)>)..::.IDictionary..::.Remove Method
ConcurrentDictionary<(Of <(TKey, TValue>)>) Class See Also Send Feedback

Removes the element with the specified key from the IDictionary.

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

Syntax

Visual Basic (Declaration)
Private Sub Remove ( _
    key As Object _
) Implements IDictionary.Remove
C#
void IDictionary.Remove(
    Object key
)

Parameters

key
Type: System..::.Object
The key of the element to remove.

Implements

IDictionary..::.Remove(Object)

Exceptions

Exception | Condition
System..::.ArgumentNullException | key is a null reference (Nothing in Visual Basic).

See Also

ConcurrentDictionary<(Of <(TKey, TValue>)>) Class
System.Collections.Concurrent Namespace


AddOrUpdate Method

[image] [image]

.NET Framework Class Library
ConcurrentDictionary<(Of <(TKey, TValue>)>)..::.AddOrUpdate Method
ConcurrentDictionary<(Of <(TKey, TValue>)>) Class See Also Send Feedback

Overload List

Name | Description
AddOrUpdate(TKey, Func<(Of <(TKey, TValue>)>), Func<(Of <(TKey, TValue, TValue>)>)) | Adds a key/value pair to the ConcurrentDictionary<(Of <(TKey, TValue>)>) if the key does not already exist, or updates a key/value pair in the ConcurrentDictionary<(Of <(TKey, TValue>)>) if the key already exists.
AddOrUpdate(TKey, TValue, Func<(Of <(TKey, TValue, TValue>)>)) | Adds a key/value pair to the ConcurrentDictionary<(Of <(TKey, TValue>)>) if the key does not already exist, or updates a key/value pair in the ConcurrentDictionary<(Of <(TKey, TValue>)>) if the key already exists.

See Also

ConcurrentDictionary<(Of <(TKey, TValue>)>) Class
System.Collections.Concurrent Namespace


AddOrUpdate Method (TKey, Func(TKey, TValue), Func(TKey, TValue, TValue))

[image]

.NET Framework Class Library
ConcurrentDictionary<(Of <(TKey, TValue>)>)..::.AddOrUpdate Method (TKey, Func<(Of <(TKey, TValue>)>), Func<(Of <(TKey, TValue, TValue>)>))
ConcurrentDictionary<(Of <(TKey, TValue>)>) Class See Also Send Feedback

Adds a key/value pair to the ConcurrentDictionary<(Of <(TKey, TValue>)>) if the key does not already exist, or updates a key/value pair in the ConcurrentDictionary<(Of <(TKey, TValue>)>) if the key already exists.

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

Syntax

Visual Basic (Declaration)
Public Function AddOrUpdate ( _
    key As TKey, _
    addValueFactory As Func(Of TKey, TValue), _
    updateValueFactory As Func(Of TKey, TValue, TValue) _
) As TValue
C#
public TValue AddOrUpdate(
    TKey key,
    Func<TKey, TValue> addValueFactory,
    Func<TKey, TValue, TValue> updateValueFactory
)

Parameters

key
Type: TKey
The key to be added or whose value should be updated
addValueFactory
Type: System..::.Func<(Of <( TKey, TValue >)>)
The function used to generate a value for an absent key
updateValueFactory
Type: System..::.Func<(Of <( TKey, TValue, TValue >)>)
The function used to generate a new value for an existing key based on the key's existing value

Return Value

The new value for the key. This will be either be the result of addValueFactory (if the key was absent) or the result of updateValueFactory (if the key was present).

Exceptions

Exception | Condition
System..::.ArgumentNullException | key is a null reference (Nothing in Visual Basic).
System..::.ArgumentNullException | addValueFactory is a null reference (Nothing in Visual Basic).
System..::.ArgumentNullException | updateValueFactory is a null reference (Nothing in Visual Basic).
System..::.OverflowException | The dictionary contains too many elements.

See Also

ConcurrentDictionary<(Of <(TKey, TValue>)>) Class
AddOrUpdate Overload
System.Collections.Concurrent Namespace


AddOrUpdate Method (TKey, TValue, Func(TKey, TValue, TValue))

[image]

.NET Framework Class Library
ConcurrentDictionary<(Of <(TKey, TValue>)>)..::.AddOrUpdate Method (TKey, TValue, Func<(Of <(TKey, TValue, TValue>)>))
ConcurrentDictionary<(Of <(TKey, TValue>)>) Class See Also Send Feedback

Adds a key/value pair to the ConcurrentDictionary<(Of <(TKey, TValue>)>) if the key does not already exist, or updates a key/value pair in the ConcurrentDictionary<(Of <(TKey, TValue>)>) if the key already exists.

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

Syntax

Visual Basic (Declaration)
Public Function AddOrUpdate ( _
    key As TKey, _
    addValue As TValue, _
    updateValueFactory As Func(Of TKey, TValue, TValue) _
) As TValue
C#
public TValue AddOrUpdate(
    TKey key,
    TValue addValue,
    Func<TKey, TValue, TValue> updateValueFactory
)

Parameters

key
Type: TKey
The key to be added or whose value should be updated
addValue
Type: TValue
The value to be added for an absent key
updateValueFactory
Type: System..::.Func<(Of <( TKey, TValue, TValue >)>)
The function used to generate a new value for an existing key based on the key's existing value

Return Value

The new value for the key. This will be either be the result of addValueFactory (if the key was absent) or the result of updateValueFactory (if the key was present).

Exceptions

Exception | Condition
System..::.ArgumentNullException | key is a null reference (Nothing in Visual Basic).
System..::.ArgumentNullException | updateValueFactory is a null reference (Nothing in Visual Basic).
System..::.OverflowException | The dictionary contains too many elements.

See Also

ConcurrentDictionary<(Of <(TKey, TValue>)>) Class
AddOrUpdate Overload
System.Collections.Concurrent Namespace


Clear Method

[image]

.NET Framework Class Library
ConcurrentDictionary<(Of <(TKey, TValue>)>)..::.Clear Method
ConcurrentDictionary<(Of <(TKey, TValue>)>) Class See Also Send Feedback

Removes all keys and values from the ConcurrentDictionary<(Of <(TKey, TValue>)>).

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

Syntax

Visual Basic (Declaration)
Public Sub Clear
C#
public void Clear()

Implements

ICollection<(Of <(T>)>)..::.Clear()()()
IDictionary..::.Clear()()()

See Also

ConcurrentDictionary<(Of <(TKey, TValue>)>) Class
System.Collections.Concurrent Namespace


ContainsKey Method

[image]

.NET Framework Class Library
ConcurrentDictionary<(Of <(TKey, TValue>)>)..::.ContainsKey Method
ConcurrentDictionary<(Of <(TKey, TValue>)>) Class See Also Send Feedback

Determines whether the ConcurrentDictionary<(Of <(TKey, TValue>)>) contains the specified key.

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

Syntax

Visual Basic (Declaration)
Public Function ContainsKey ( _
    key As TKey _
) As Boolean
C#
public bool ContainsKey(
    TKey key
)

Parameters

key
Type: TKey
The key to locate in the ConcurrentDictionary<(Of <(TKey, TValue>)>).

Return Value

true if the ConcurrentDictionary<(Of <(TKey, TValue>)>) contains an element with the specified key; otherwise, false.

Implements

IDictionary<(Of <(TKey, TValue>)>)..::.ContainsKey(TKey)

Exceptions

Exception | Condition
System..::.ArgumentNullException | key is a null reference (Nothing in Visual Basic).

See Also

ConcurrentDictionary<(Of <(TKey, TValue>)>) Class
System.Collections.Concurrent Namespace


GetEnumerator Method

[image]

.NET Framework Class Library
ConcurrentDictionary<(Of <(TKey, TValue>)>)..::.GetEnumerator Method
ConcurrentDictionary<(Of <(TKey, TValue>)>) Class See Also Send Feedback

Returns an enumerator that iterates through the ConcurrentDictionary<(Of <(TKey, TValue>)>).

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

Syntax

Visual Basic (Declaration)
Public Function GetEnumerator As IEnumerator(Of KeyValuePair(Of TKey, TValue))
C#
public IEnumerator<KeyValuePair<TKey, TValue>> GetEnumerator()

Return Value

An enumerator for the ConcurrentDictionary<(Of <(TKey, TValue>)>).

Implements

IEnumerable<(Of <(T>)>)..::.GetEnumerator()()()

Remarks

The enumerator returned from the dictionary is safe to use concurrently with reads and writes to the dictionary, however it does not represent a moment-in-time snapshot of the dictionary. The contents exposed through the enumerator may contain modifications made to the dictionary after GetEnumerator()()() was called.

See Also

ConcurrentDictionary<(Of <(TKey, TValue>)>) Class
System.Collections.Concurrent Namespace


GetOrAdd Method

[image] [image]

.NET Framework Class Library
ConcurrentDictionary<(Of <(TKey, TValue>)>)..::.GetOrAdd Method
ConcurrentDictionary<(Of <(TKey, TValue>)>) Class See Also Send Feedback

Overload List

Name | Description
GetOrAdd(TKey, Func<(Of <(TKey, TValue>)>)) | Adds a key/value pair to the ConcurrentDictionary<(Of <(TKey, TValue>)>) if the key does not already exist.
GetOrAdd(TKey, TValue) | Adds a key/value pair to the ConcurrentDictionary<(Of <(TKey, TValue>)>) if the key does not already exist.

See Also

ConcurrentDictionary<(Of <(TKey, TValue>)>) Class
System.Collections.Concurrent Namespace


GetOrAdd Method (TKey, Func(TKey, TValue))

[image]

.NET Framework Class Library
ConcurrentDictionary<(Of <(TKey, TValue>)>)..::.GetOrAdd Method (TKey, Func<(Of <(TKey, TValue>)>))
ConcurrentDictionary<(Of <(TKey, TValue>)>) Class See Also Send Feedback

Adds a key/value pair to the ConcurrentDictionary<(Of <(TKey, TValue>)>) if the key does not already exist.

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

Syntax

Visual Basic (Declaration)
Public Function GetOrAdd ( _
    key As TKey, _
    valueFactory As Func(Of TKey, TValue) _
) As TValue
C#
public TValue GetOrAdd(
    TKey key,
    Func<TKey, TValue> valueFactory
)

Parameters

key
Type: TKey
The key of the element to add.
valueFactory
Type: System..::.Func<(Of <( TKey, TValue >)>)
The function used to generate a value for the key

Return Value

The value for the key. This will be either the existing value for the key if the key is already in the dictionary, or the new value for the key as returned by valueFactory if the key was not in the dictionary.

Exceptions

Exception | Condition
System..::.ArgumentNullException | key is a null reference (Nothing in Visual Basic).
System..::.ArgumentNullException | valueFactory is a null reference (Nothing in Visual Basic).
System..::.OverflowException | The dictionary contains too many elements.

See Also

ConcurrentDictionary<(Of <(TKey, TValue>)>) Class
GetOrAdd Overload
System.Collections.Concurrent Namespace


GetOrAdd Method (TKey, TValue)

[image]

.NET Framework Class Library
ConcurrentDictionary<(Of <(TKey, TValue>)>)..::.GetOrAdd Method (TKey, TValue)
ConcurrentDictionary<(Of <(TKey, TValue>)>) Class See Also Send Feedback

Adds a key/value pair to the ConcurrentDictionary<(Of <(TKey, TValue>)>) if the key does not already exist.

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

Syntax

Visual Basic (Declaration)
Public Function GetOrAdd ( _
    key As TKey, _
    value As TValue _
) As TValue
C#
public TValue GetOrAdd(
    TKey key,
    TValue value
)

Parameters

key
Type: TKey
The key of the element to add.
value
Type: TValue
the value to be added, if the key does not already exist

Return Value

The value for the key. This will be either the existing value for the key if the key is already in the dictionary, or the new value if the key was not in the dictionary.

Exceptions

Exception | Condition
System..::.ArgumentNullException | key is a null reference (Nothing in Visual Basic).
System..::.OverflowException | The dictionary contains too many elements.

See Also

ConcurrentDictionary<(Of <(TKey, TValue>)>) Class
GetOrAdd Overload
System.Collections.Concurrent Namespace


ToArray Method

[image]

.NET Framework Class Library
ConcurrentDictionary<(Of <(TKey, TValue>)>)..::.ToArray Method
ConcurrentDictionary<(Of <(TKey, TValue>)>) Class See Also Send Feedback

Copies the key and value pairs stored in the ConcurrentDictionary<(Of <(TKey, TValue>)>) to a new array.

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

Syntax

Visual Basic (Declaration)
Public Function ToArray As KeyValuePair(Of TKey, TValue)()
C#
public KeyValuePair<TKey, TValue>[] ToArray()

Return Value

A new array containing a snapshot of key and value pairs copied from the ConcurrentDictionary<(Of <(TKey, TValue>)>).

See Also

ConcurrentDictionary<(Of <(TKey, TValue>)>) Class
System.Collections.Concurrent Namespace


TryAdd Method

[image]

.NET Framework Class Library
ConcurrentDictionary<(Of <(TKey, TValue>)>)..::.TryAdd Method
ConcurrentDictionary<(Of <(TKey, TValue>)>) Class See Also Send Feedback

Attempts to add the specified key and value to the ConcurrentDictionary<(Of <(TKey, TValue>)>).

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

Syntax

Visual Basic (Declaration)
Public Function TryAdd ( _
    key As TKey, _
    value As TValue _
) As Boolean
C#
public bool TryAdd(
    TKey key,
    TValue value
)

Parameters

key
Type: TKey
The key of the element to add.
value
Type: TValue
The value of the element to add. The value can be a null reference (Nothing in Visual Basic) for reference types.

Return Value

true if the key/value pair was added to the ConcurrentDictionary<(Of <(TKey, TValue>)>) successfully; otherwise, false.

Exceptions

Exception | Condition
System..::.ArgumentNullException | key is null reference (Nothing in Visual Basic).
System..::.OverflowException | The ConcurrentDictionary<(Of <(TKey, TValue>)>) contains too many elements.

See Also

ConcurrentDictionary<(Of <(TKey, TValue>)>) Class
System.Collections.Concurrent Namespace


TryGetValue Method

[image]

.NET Framework Class Library
ConcurrentDictionary<(Of <(TKey, TValue>)>)..::.TryGetValue Method
ConcurrentDictionary<(Of <(TKey, TValue>)>) Class See Also Send Feedback

Attempts to get the value associated with the specified key from the ConcurrentDictionary<(Of <(TKey, TValue>)>).

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

Syntax

Visual Basic (Declaration)
Public Function TryGetValue ( _
    key As TKey, _
    <OutAttribute> ByRef value As TValue _
) As Boolean
C#
public bool TryGetValue(
    TKey key,
    out TValue value
)

Parameters

key
Type: TKey
The key of the value to get.
value
Type: TValue %
When this method returns, value contains the object from the ConcurrentDictionary<(Of <(TKey, TValue>)>) with the spedified key or the default value of TValue, if the operation failed.

Return Value

true if the key was found in the ConcurrentDictionary<(Of <(TKey, TValue>)>); otherwise, false.

Implements

IDictionary<(Of <(TKey, TValue>)>)..::.TryGetValue(TKey, TValue%)

Exceptions

Exception | Condition
System..::.ArgumentNullException | key is a null reference (Nothing in Visual Basic).

See Also

ConcurrentDictionary<(Of <(TKey, TValue>)>) Class
System.Collections.Concurrent Namespace


TryRemove Method

[image]

.NET Framework Class Library
ConcurrentDictionary<(Of <(TKey, TValue>)>)..::.TryRemove Method
ConcurrentDictionary<(Of <(TKey, TValue>)>) Class See Also Send Feedback

Attempts to remove and return the the value with the specified key from the ConcurrentDictionary<(Of <(TKey, TValue>)>).

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

Syntax

Visual Basic (Declaration)
Public Function TryRemove ( _
    key As TKey, _
    <OutAttribute> ByRef value As TValue _
) As Boolean
C#
public bool TryRemove(
    TKey key,
    out TValue value
)

Parameters

key
Type: TKey
The key of the element to remove and return.
value
Type: TValue %
When this method returns, value contains the object removed from the ConcurrentDictionary<(Of <(TKey, TValue>)>) or the default value of TValue if the operation failed.

Return Value

true if an object was removed successfully; otherwise, false.

Exceptions

Exception | Condition
System..::.ArgumentNullException | key is a null reference (Nothing in Visual Basic).

See Also

ConcurrentDictionary<(Of <(TKey, TValue>)>) Class
System.Collections.Concurrent Namespace


TryUpdate Method

[image]

.NET Framework Class Library
ConcurrentDictionary<(Of <(TKey, TValue>)>)..::.TryUpdate Method
ConcurrentDictionary<(Of <(TKey, TValue>)>) Class See Also Send Feedback

Compares the existing value for the specified key with a specified value, and if they’re equal, updates the key with a third value.

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

Syntax

Visual Basic (Declaration)
Public Function TryUpdate ( _
    key As TKey, _
    newValue As TValue, _
    comparisonValue As TValue _
) As Boolean
C#
public bool TryUpdate(
    TKey key,
    TValue newValue,
    TValue comparisonValue
)

Parameters

key
Type: TKey
The key whose value is compared with comparisonValue and possibly replaced.
newValue
Type: TValue
The value that replaces the value of the element with key if the comparison results in equality.
comparisonValue
Type: TValue
The value that is compared to the value of the element with key.

Return Value

true if the value with key was equal to comparisonValue and replaced with newValue; otherwise, false.

Exceptions

Exception | Condition
System..::.ArgumentNullException | key is a null reference.

See Also

ConcurrentDictionary<(Of <(TKey, TValue>)>) Class
System.Collections.Concurrent Namespace


ConcurrentDictionary(TKey, TValue) Properties

[image] [image]

.NET Framework Class Library
ConcurrentDictionary<(Of <(TKey, TValue>)>) Properties
ConcurrentDictionary<(Of <(TKey, TValue>)>) Class See Also Send Feedback

The ConcurrentDictionary<(Of <(TKey, TValue>)>) type exposes the following members.

Properties

Name | Description
Count | Gets the number of key/value pairs contained in the ConcurrentDictionary<(Of <(TKey, TValue>)>).
IsEmpty | Gets a value that indicates whether the ConcurrentDictionary<(Of <(TKey, TValue>)>) is empty.
Item | Gets or sets the value associated with the specified key.
Keys | Gets a collection containing the keys in the Dictionary<(Of <(TKey, TValue>)>).
Values | Gets a collection containing the values in the Dictionary<(Of <(TKey, TValue>)>).

Explicit Interface Implementations

Name | Description
IDictionary..::.IsFixedSize | Gets a value indicating whether the IDictionary<(Of <(TKey, TValue>)>) has a fixed size.
ICollection<(Of <(KeyValuePair<(Of <(TKey, TValue>)>)>)>)..::.IsReadOnly |
IDictionary..::.IsReadOnly | Gets a value indicating whether the IDictionary<(Of <(TKey, TValue>)>) is read-only.
ICollection..::.IsSynchronized | Gets a value indicating whether access to the ICollection is synchronized with the SyncRoot.
IDictionary..::.Item | Gets or sets the value associated with the specified key.
IDictionary..::.Keys | Gets an ICollection containing the keys of the IDictionary<(Of <(TKey, TValue>)>).
ICollection..::.SyncRoot | Gets an object that can be used to synchronize access to the ICollection. This property is not supported.
IDictionary..::.Values | Gets an ICollection containing the values in the IDictionary.

See Also

ConcurrentDictionary<(Of <(TKey, TValue>)>) Class
System.Collections.Concurrent Namespace


IDictionary.IsFixedSize Property

[image]

.NET Framework Class Library
ConcurrentDictionary<(Of <(TKey, TValue>)>)..::.IDictionary..::.IsFixedSize Property
ConcurrentDictionary<(Of <(TKey, TValue>)>) Class See Also Send Feedback

Gets a value indicating whether the IDictionary<(Of <(TKey, TValue>)>) has a fixed size.

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

Syntax

Visual Basic (Declaration)
Private ReadOnly Property IsFixedSize As Boolean
    Implements IDictionary.IsFixedSize
C#
bool IDictionary.IsFixedSize { get; }

Field Value

true if the IDictionary<(Of <(TKey, TValue>)>) has a fixed size; otherwise, false. For ConcurrentDictionary<(Of <(TKey, TValue>)>), this property always returns false.

Implements

IDictionary..::.IsFixedSize

See Also

ConcurrentDictionary<(Of <(TKey, TValue>)>) Class
System.Collections.Concurrent Namespace


ICollection(KeyValuePair(TKey, TValue)).IsReadOnly Property

[image]

.NET Framework Class Library
ConcurrentDictionary<(Of <(TKey, TValue>)>)..::.ICollection<(Of <(KeyValuePair<(Of <(TKey, TValue>)>)>)>)..::.IsReadOnly Property
ConcurrentDictionary<(Of <(TKey, TValue>)>) Class See Also Send Feedback

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

Syntax

Visual Basic (Declaration)
Private ReadOnly Property IsReadOnly As Boolean
    Implements ICollection(Of KeyValuePair(Of TKey, TValue)).IsReadOnly
C#
bool ICollection<KeyValuePair<TKey, TValue>>.IsReadOnly { get; }

Implements

ICollection<(Of <(T>)>)..::.IsReadOnly

See Also

ConcurrentDictionary<(Of <(TKey, TValue>)>) Class
System.Collections.Concurrent Namespace


IDictionary.IsReadOnly Property

[image]

.NET Framework Class Library
ConcurrentDictionary<(Of <(TKey, TValue>)>)..::.IDictionary..::.IsReadOnly Property
ConcurrentDictionary<(Of <(TKey, TValue>)>) Class See Also Send Feedback

Gets a value indicating whether the IDictionary<(Of <(TKey, TValue>)>) is read-only.

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

Syntax

Visual Basic (Declaration)
Private ReadOnly Property IsReadOnly As Boolean
    Implements IDictionary.IsReadOnly
C#
bool IDictionary.IsReadOnly { get; }

Field Value

true if the IDictionary<(Of <(TKey, TValue>)>) is read-only; otherwise, false. For ConcurrentDictionary<(Of <(TKey, TValue>)>), this property always returns false.

Implements

IDictionary..::.IsReadOnly

See Also

ConcurrentDictionary<(Of <(TKey, TValue>)>) Class
System.Collections.Concurrent Namespace


ICollection.IsSynchronized Property

[image]

.NET Framework Class Library
ConcurrentDictionary<(Of <(TKey, TValue>)>)..::.ICollection..::.IsSynchronized Property
ConcurrentDictionary<(Of <(TKey, TValue>)>) Class See Also Send Feedback

Gets a value indicating whether access to the ICollection is synchronized with the SyncRoot.

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

Syntax

Visual Basic (Declaration)
Private ReadOnly Property IsSynchronized As Boolean
    Implements ICollection.IsSynchronized
C#
bool ICollection.IsSynchronized { get; }

Field Value

true if access to the ICollection is synchronized (thread safe); otherwise, false. For ConcurrentDictionary<(Of <(TKey, TValue>)>), this property always returns false.

Implements

ICollection..::.IsSynchronized

See Also

ConcurrentDictionary<(Of <(TKey, TValue>)>) Class
System.Collections.Concurrent Namespace


IDictionary.Item Property

[image]

.NET Framework Class Library
ConcurrentDictionary<(Of <(TKey, TValue>)>)..::.IDictionary..::.Item Property
ConcurrentDictionary<(Of <(TKey, TValue>)>) Class See Also Send Feedback

Gets or sets the value associated with the specified key.

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

Syntax

Visual Basic (Declaration)
Private Property Item ( _
    key As Object _
) As Object Implements IDictionary.Item
C#
Object IDictionary.Item[
    Object key
] { get; set; }

Parameters

key
Type: System..::.Object
The key of the value to get or set.

Field Value

The value associated with the specified key, or a null reference (Nothing in Visual Basic) if key is not in the dictionary or key is of a type that is not assignable to the key type TKey of the ConcurrentDictionary<(Of <(TKey, TValue>)>).

Implements

IDictionary..::.Item[([(Object])])

Exceptions

Exception | Condition
System..::.ArgumentNullException | key is a null reference (Nothing in Visual Basic).
System..::.ArgumentException | A value is being assigned, and key is of a type that is not assignable to the key type TKey of the ConcurrentDictionary<(Of <(TKey, TValue>)>). -or- A value is being assigned, and key is of a type that is not assignable to the value type TValue of the ConcurrentDictionary<(Of <(TKey, TValue>)>)

See Also

ConcurrentDictionary<(Of <(TKey, TValue>)>) Class
System.Collections.Concurrent Namespace


IDictionary.Keys Property

[image]

.NET Framework Class Library
ConcurrentDictionary<(Of <(TKey, TValue>)>)..::.IDictionary..::.Keys Property
ConcurrentDictionary<(Of <(TKey, TValue>)>) Class See Also Send Feedback

Gets an ICollection containing the keys of the IDictionary<(Of <(TKey, TValue>)>).

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

Syntax

Visual Basic (Declaration)
Private ReadOnly Property Keys As ICollection
    Implements IDictionary.Keys
C#
ICollection IDictionary.Keys { get; }

Field Value

An ICollection containing the keys of the IDictionary<(Of <(TKey, TValue>)>).

Implements

IDictionary..::.Keys

See Also

ConcurrentDictionary<(Of <(TKey, TValue>)>) Class
System.Collections.Concurrent Namespace


ICollection.SyncRoot Property

[image]

.NET Framework Class Library
ConcurrentDictionary<(Of <(TKey, TValue>)>)..::.ICollection..::.SyncRoot Property
ConcurrentDictionary<(Of <(TKey, TValue>)>) Class See Also Send Feedback

Gets an object that can be used to synchronize access to the ICollection. This property is not supported.

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

Syntax

Visual Basic (Declaration)
Private ReadOnly Property SyncRoot As Object
    Implements ICollection.SyncRoot
C#
Object ICollection.SyncRoot { get; }

Implements

ICollection..::.SyncRoot

Exceptions

Exception | Condition
System..::.NotSupportedException | The SyncRoot property is not supported.

See Also

ConcurrentDictionary<(Of <(TKey, TValue>)>) Class
System.Collections.Concurrent Namespace


IDictionary.Values Property

[image]

.NET Framework Class Library
ConcurrentDictionary<(Of <(TKey, TValue>)>)..::.IDictionary..::.Values Property
ConcurrentDictionary<(Of <(TKey, TValue>)>) Class See Also Send Feedback

Gets an ICollection containing the values in the IDictionary.

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

Syntax

Visual Basic (Declaration)
Private ReadOnly Property Values As ICollection
    Implements IDictionary.Values
C#
ICollection IDictionary.Values { get; }

Field Value

An ICollection containing the values in the IDictionary.

Implements

IDictionary..::.Values

See Also

ConcurrentDictionary<(Of <(TKey, TValue>)>) Class
System.Collections.Concurrent Namespace


Count Property

[image]

.NET Framework Class Library
ConcurrentDictionary<(Of <(TKey, TValue>)>)..::.Count Property
ConcurrentDictionary<(Of <(TKey, TValue>)>) Class See Also Send Feedback

Gets the number of key/value pairs contained in the ConcurrentDictionary<(Of <(TKey, TValue>)>).

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

Syntax

Visual Basic (Declaration)
Public ReadOnly Property Count As Integer
C#
public int Count { get; }

Field Value

The number of key/value paris contained in the ConcurrentDictionary<(Of <(TKey, TValue>)>).

Implements

ICollection<(Of <(T>)>)..::.Count
ICollection..::.Count

Remarks

Count has snapshot semantics and represents the number of items in the ConcurrentDictionary<(Of <(TKey, TValue>)>) at the moment when Count was accessed.

Exceptions

Exception | Condition
System..::.OverflowException | The dictionary contains too many elements.

See Also

ConcurrentDictionary<(Of <(TKey, TValue>)>) Class
System.Collections.Concurrent Namespace


IsEmpty Property

[image]

.NET Framework Class Library
ConcurrentDictionary<(Of <(TKey, TValue>)>)..::.IsEmpty Property
ConcurrentDictionary<(Of <(TKey, TValue>)>) Class See Also Send Feedback

Gets a value that indicates whether the ConcurrentDictionary<(Of <(TKey, TValue>)>) is empty.

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

Syntax

Visual Basic (Declaration)
Public ReadOnly Property IsEmpty As Boolean
C#
public bool IsEmpty { get; }

Field Value

true if the ConcurrentDictionary<(Of <(TKey, TValue>)>) is empty; otherwise, false.

See Also

ConcurrentDictionary<(Of <(TKey, TValue>)>) Class
System.Collections.Concurrent Namespace


Item Property

[image]

.NET Framework Class Library
ConcurrentDictionary<(Of <(TKey, TValue>)>)..::.Item Property
ConcurrentDictionary<(Of <(TKey, TValue>)>) Class See Also Send Feedback

Gets or sets the value associated with the specified key.

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

Syntax

Visual Basic (Declaration)
Public Property Item ( _
    key As TKey _
) As TValue
C#
public TValue Item[
    TKey key
] { get; set; }

Parameters

key
Type: TKey
The key of the value to get or set.

Field Value

The value associated with the specified key. If the specified key is not found, a get operation throws a KeyNotFoundException, and a set operation creates a new element with the specified key.

Implements

IDictionary<(Of <(TKey, TValue>)>)..::.Item[([(TKey])])

Exceptions

Exception | Condition
System..::.ArgumentNullException | key is a null reference (Nothing in Visual Basic).
System.Collections.Generic..::.KeyNotFoundException | The property is retrieved and key does not exist in the collection.

See Also

ConcurrentDictionary<(Of <(TKey, TValue>)>) Class
System.Collections.Concurrent Namespace


Keys Property

[image]

.NET Framework Class Library
ConcurrentDictionary<(Of <(TKey, TValue>)>)..::.Keys Property
ConcurrentDictionary<(Of <(TKey, TValue>)>) Class See Also Send Feedback

Gets a collection containing the keys in the Dictionary<(Of <(TKey, TValue>)>).

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

Syntax

Visual Basic (Declaration)
Public ReadOnly Property Keys As ICollection(Of TKey)
C#
public ICollection<TKey> Keys { get; }

Field Value

An ICollection<(Of <(TKey>)>) containing the keys in the Dictionary<(Of <(TKey, TValue>)>).

Implements

IDictionary<(Of <(TKey, TValue>)>)..::.Keys

See Also

ConcurrentDictionary<(Of <(TKey, TValue>)>) Class
System.Collections.Concurrent Namespace


Values Property

[image]

.NET Framework Class Library
ConcurrentDictionary<(Of <(TKey, TValue>)>)..::.Values Property
ConcurrentDictionary<(Of <(TKey, TValue>)>) Class See Also Send Feedback

Gets a collection containing the values in the Dictionary<(Of <(TKey, TValue>)>).

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

Syntax

Visual Basic (Declaration)
Public ReadOnly Property Values As ICollection(Of TValue)
C#
public ICollection<TValue> Values { get; }

Field Value

An ICollection<(Of <(TValue>)>) containing the values in the Dictionary<(Of <(TKey, TValue>)>).

Implements

IDictionary<(Of <(TKey, TValue>)>)..::.Values

See Also

ConcurrentDictionary<(Of <(TKey, TValue>)>) Class
System.Collections.Concurrent Namespace


ConcurrentQueue(T) Class

[image]

.NET Framework Class Library
ConcurrentQueue<(Of <(T>)>) Class
See Also Send Feedback

Represents a thread-safe first-in, first-out collection of objects.

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

Syntax

Visual Basic (Declaration)
<SerializableAttribute> _
<ComVisibleAttribute(False)> _
<HostProtectionAttribute(SecurityAction.LinkDemand, Synchronization := True,  _
    ExternalThreading := True)> _
Public Class ConcurrentQueue(Of T) _
    Implements IProducerConsumerCollection(Of T), IEnumerable(Of T),  _
    ICollection, IEnumerable
C#
[SerializableAttribute]
[ComVisibleAttribute(false)]
[HostProtectionAttribute(SecurityAction.LinkDemand, Synchronization = true,
    ExternalThreading = true)]
public class ConcurrentQueue<T> : IProducerConsumerCollection<T>,
    IEnumerable<T>, ICollection, IEnumerable

Type Parameters

T
Specifies the type of elements in the queue.

Remarks

All public and protected members of ConcurrentQueue<(Of <(T>)>) are thread-safe and may be used concurrently from multiple threads.

Inheritance Hierarchy

System..::.Object
System.Collections.Concurrent..::.ConcurrentQueue<(Of <(T>)>)

See Also

System.Collections.Concurrent Namespace


ConcurrentQueue(T) Constructor

[image] [image]

.NET Framework Class Library
ConcurrentQueue<(Of <(T>)>) Constructor
ConcurrentQueue<(Of <(T>)>) Class See Also Send Feedback

Overload List

Name | Description
ConcurrentQueue<(Of <(T>)>)()()() | Initializes a new instance of the ConcurrentQueue<(Of <(T>)>) class.
ConcurrentQueue<(Of <(T>)>)(IEnumerable<(Of <(T>)>)) | Initializes a new instance of the ConcurrentQueue<(Of <(T>)>) class that contains elements copied from the specified collection

See Also

ConcurrentQueue<(Of <(T>)>) Class
System.Collections.Concurrent Namespace


ConcurrentQueue(T) Constructor

[image]

.NET Framework Class Library
ConcurrentQueue<(Of <(T>)>) Constructor
ConcurrentQueue<(Of <(T>)>) Class See Also Send Feedback

Initializes a new instance of the ConcurrentQueue<(Of <(T>)>) class.

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

Syntax

Visual Basic (Declaration)
Public Sub New
C#
public ConcurrentQueue()

See Also

ConcurrentQueue<(Of <(T>)>) Class
ConcurrentQueue<(Of <(T>)>) Overload
System.Collections.Concurrent Namespace


ConcurrentQueue(T) Constructor (IEnumerable(T))

[image]

.NET Framework Class Library
ConcurrentQueue<(Of <(T>)>) Constructor (IEnumerable<(Of <(T>)>))
ConcurrentQueue<(Of <(T>)>) Class See Also Send Feedback

Initializes a new instance of the ConcurrentQueue<(Of <(T>)>) class that contains elements copied from the specified collection

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

Syntax

Visual Basic (Declaration)
Public Sub New ( _
    collection As IEnumerable(Of T) _
)
C#
public ConcurrentQueue(
    IEnumerable<T> collection
)

Parameters

collection
Type: System.Collections.Generic..::.IEnumerable<(Of <( T >)>)
The collection whose elements are copied to the new ConcurrentQueue<(Of <(T>)>).

Exceptions

Exception | Condition
System..::.ArgumentNullException | The collection argument is null.

See Also

ConcurrentQueue<(Of <(T>)>) Class
ConcurrentQueue<(Of <(T>)>) Overload
System.Collections.Concurrent Namespace


ConcurrentQueue(T) Methods

[image] [image]

.NET Framework Class Library
ConcurrentQueue<(Of <(T>)>) Methods
ConcurrentQueue<(Of <(T>)>) Class See Also Send Feedback

The ConcurrentQueue<(Of <(T>)>) type exposes the following members.

Methods

Name | Description
CopyTo | Copies the ConcurrentQueue<(Of <(T>)>) elements to an existing one-dimensional Array, starting at the specified array index.
Enqueue | Adds an object to the end of the ConcurrentQueue<(Of <(T>)>).
Equals | (Inherited from Object.)
Finalize | (Inherited from Object.)
GetEnumerator | Returns an enumerator that iterates through the ConcurrentQueue<(Of <(T>)>).
GetHashCode | (Inherited from Object.)
GetType | (Inherited from Object.)
MemberwiseClone | (Inherited from Object.)
ToArray | Copies the elements stored in the ConcurrentQueue<(Of <(T>)>) to a new array.
ToString | (Inherited from Object.)
TryDequeue | Attempts to remove and return the object at the beginning of the ConcurrentQueue<(Of <(T>)>).
TryPeek | Attempts to return an object from the beginning of the ConcurrentQueue<(Of <(T>)>) without removing it.

Explicit Interface Implementations

Name | Description
ICollection..::.CopyTo | Copies the elements of the ICollection to an Array, starting at a particular Array index.
IEnumerable..::.GetEnumerator | Returns an enumerator that iterates through a collection.
IProducerConsumerCollection<(Of <(T>)>)..::.TryAdd | Attempts to add an object to the IProducerConsumerCollection<(Of <(T>)>).
IProducerConsumerCollection<(Of <(T>)>)..::.TryTake | Attempts to remove and return an object from the IProducerConsumerCollection<(Of <(T>)>).

See Also

ConcurrentQueue<(Of <(T>)>) Class
System.Collections.Concurrent Namespace


ICollection.CopyTo Method

[image]

.NET Framework Class Library
ConcurrentQueue<(Of <(T>)>)..::.ICollection..::.CopyTo Method
ConcurrentQueue<(Of <(T>)>) Class See Also Send Feedback

Copies the elements of the ICollection to an Array, starting at a particular Array index.

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

Syntax

Visual Basic (Declaration)
Private Sub CopyTo ( _
    array As Array, _
    index As Integer _
) Implements ICollection.CopyTo
C#
void ICollection.CopyTo(
    Array array,
    int index
)

Parameters

array
Type: System..::.Array
The one-dimensional Array that is the destination of the elements copied from the ConcurrentBag. The Array must have zero-based indexing.
index
Type: System..::.Int32
The zero-based index in array at which copying begins.

Implements

ICollection..::.CopyTo(Array, Int32)

Exceptions

Exception | Condition
System..::.ArgumentNullException | array is a null reference (Nothing in Visual Basic).
System..::.ArgumentOutOfRangeException | index is less than zero.
System..::.ArgumentException | array is multidimensional. -or- array does not have zero-based indexing. -or- index is equal to or greater than the length of the array -or- The number of elements in the source ICollection is greater than the available space from index to the end of the destination array. -or- The type of the source ICollection cannot be cast automatically to the type of the destination array.

See Also

ConcurrentQueue<(Of <(T>)>) Class
System.Collections.Concurrent Namespace


IEnumerable.GetEnumerator Method

[image]

.NET Framework Class Library
ConcurrentQueue<(Of <(T>)>)..::.IEnumerable..::.GetEnumerator Method
ConcurrentQueue<(Of <(T>)>) Class See Also Send Feedback

Returns an enumerator that iterates through a collection.

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

Syntax

Visual Basic (Declaration)
Private Function GetEnumerator As IEnumerator
    Implements IEnumerable.GetEnumerator
C#
IEnumerator IEnumerable.GetEnumerator()

Return Value

An IEnumerator that can be used to iterate through the collection.

Implements

IEnumerable..::.GetEnumerator()()()

See Also

ConcurrentQueue<(Of <(T>)>) Class
System.Collections.Concurrent Namespace


CopyTo Method

[image]

.NET Framework Class Library
ConcurrentQueue<(Of <(T>)>)..::.CopyTo Method
ConcurrentQueue<(Of <(T>)>) Class See Also Send Feedback

Copies the ConcurrentQueue<(Of <(T>)>) elements to an existing one-dimensional Array, starting at the specified array index.

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

Syntax

Visual Basic (Declaration)
Public Sub CopyTo ( _
    array As T(), _
    index As Integer _
)
C#
public void CopyTo(
    T[] array,
    int index
)

Parameters

array
Type: array< T >[]()[]
The one-dimensional Array that is the destination of the elements copied from the ConcurrentQueue<(Of <(T>)>). The Array must have zero-based indexing.
index
Type: System..::.Int32
The zero-based index in array at which copying begins.

Implements

IProducerConsumerCollection<(Of <(T>)>)..::.CopyTo(array<T>[]()[], Int32)

Exceptions

Exception | Condition
System..::.ArgumentNullException | array is a null reference (Nothing in Visual Basic).
System..::.ArgumentOutOfRangeException | index is less than zero.
System..::.ArgumentException | index is equal to or greater than the length of the array -or- The number of elements in the source ConcurrentQueue<(Of <(T>)>) is greater than the available space from index to the end of the destination array.

See Also

ConcurrentQueue<(Of <(T>)>) Class
System.Collections.Concurrent Namespace


Enqueue Method

[image]

.NET Framework Class Library
ConcurrentQueue<(Of <(T>)>)..::.Enqueue Method
ConcurrentQueue<(Of <(T>)>) Class See Also Send Feedback

Adds an object to the end of the ConcurrentQueue<(Of <(T>)>).

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

Syntax

Visual Basic (Declaration)
Public Sub Enqueue ( _
    item As T _
)
C#
public void Enqueue(
    T item
)

Parameters

item
Type: T
The object to add to the end of the ConcurrentQueue<(Of <(T>)>). The value can be a null reference (Nothing in Visual Basic) for reference types.

See Also

ConcurrentQueue<(Of <(T>)>) Class
System.Collections.Concurrent Namespace


GetEnumerator Method

[image]

.NET Framework Class Library
ConcurrentQueue<(Of <(T>)>)..::.GetEnumerator Method
ConcurrentQueue<(Of <(T>)>) Class See Also Send Feedback

Returns an enumerator that iterates through the ConcurrentQueue<(Of <(T>)>).

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

Syntax

Visual Basic (Declaration)
Public Function GetEnumerator As IEnumerator(Of T)
C#
public IEnumerator<T> GetEnumerator()

Return Value

An enumerator for the contents of the ConcurrentQueue<(Of <(T>)>).

Remarks

The enumeration represents a moment-in-time snapshot of the contents of the queue. It does not reflect any updates to the collection after GetEnumerator()()() was called. The enumerator is safe to use concurrently with reads from and writes to the queue.

See Also

ConcurrentQueue<(Of <(T>)>) Class
System.Collections.Concurrent Namespace


IProducerConsumerCollection(T).TryAdd Method

[image]

.NET Framework Class Library
ConcurrentQueue<(Of <(T>)>)..::.IProducerConsumerCollection<(Of <(T>)>)..::.TryAdd Method
ConcurrentQueue<(Of <(T>)>) Class See Also Send Feedback

Attempts to add an object to the IProducerConsumerCollection<(Of <(T>)>).

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

Syntax

Visual Basic (Declaration)
Private Function TryAdd ( _
    item As T _
) As Boolean Implements IProducerConsumerCollection(Of T).TryAdd
C#
bool IProducerConsumerCollection<T>.TryAdd(
    T item
)

Parameters

item
Type: T
The object to add to the IProducerConsumerCollection<(Of <(T>)>). The value can be a null reference (Nothing in Visual Basic) for reference types.

Return Value

true if the object was added successfully; otherwise, false.

Implements

IProducerConsumerCollection<(Of <(T>)>)..::.TryAdd(T)

Remarks

For ConcurrentQueue<(Of <(T>)>), this operation will always add the object to the end of the ConcurrentQueue<(Of <(T>)>) and return true.

See Also

ConcurrentQueue<(Of <(T>)>) Class
System.Collections.Concurrent Namespace


IProducerConsumerCollection(T).TryTake Method

[image]

.NET Framework Class Library
ConcurrentQueue<(Of <(T>)>)..::.IProducerConsumerCollection<(Of <(T>)>)..::.TryTake Method
ConcurrentQueue<(Of <(T>)>) Class See Also Send Feedback

Attempts to remove and return an object from the IProducerConsumerCollection<(Of <(T>)>).

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

Syntax

Visual Basic (Declaration)
Private Function TryTake ( _
    <OutAttribute> ByRef item As T _
) As Boolean Implements IProducerConsumerCollection(Of T).TryTake
C#
bool IProducerConsumerCollection<T>.TryTake(
    out T item
)

Parameters

item
Type: T %
When this method returns, if the operation was successful, item contains the object removed. If no object was available to be removed, the value is unspecified.

Return Value

true if an element was removed and returned succesfully; otherwise, false.

Implements

IProducerConsumerCollection<(Of <(T>)>)..::.TryTake(T%)

Remarks

For ConcurrentQueue<(Of <(T>)>), this operation will attempt to remove the object from the beginning of the ConcurrentQueue<(Of <(T>)>).

See Also

ConcurrentQueue<(Of <(T>)>) Class
System.Collections.Concurrent Namespace


ToArray Method

[image]

.NET Framework Class Library
ConcurrentQueue<(Of <(T>)>)..::.ToArray Method
ConcurrentQueue<(Of <(T>)>) Class See Also Send Feedback

Copies the elements stored in the ConcurrentQueue<(Of <(T>)>) to a new array.

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

Syntax

Visual Basic (Declaration)
Public Function ToArray As T()
C#
public T[] ToArray()

Return Value

A new array containing a snapshot of elements copied from the ConcurrentQueue<(Of <(T>)>).

Implements

IProducerConsumerCollection<(Of <(T>)>)..::.ToArray()()()

See Also

ConcurrentQueue<(Of <(T>)>) Class
System.Collections.Concurrent Namespace


TryDequeue Method

[image]

.NET Framework Class Library
ConcurrentQueue<(Of <(T>)>)..::.TryDequeue Method
ConcurrentQueue<(Of <(T>)>) Class See Also Send Feedback

Attempts to remove and return the object at the beginning of the ConcurrentQueue<(Of <(T>)>).

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

Syntax

Visual Basic (Declaration)
Public Function TryDequeue ( _
    <OutAttribute> ByRef result As T _
) As Boolean
C#
public bool TryDequeue(
    out T result
)

Parameters

result
Type: T %
When this method returns, if the operation was successful, result contains the object removed. If no object was available to be removed, the value is unspecified.

Return Value

true if an element was removed and returned from the beggining of the ConcurrentQueue<(Of <(T>)>) succesfully; otherwise, false.

See Also

ConcurrentQueue<(Of <(T>)>) Class
System.Collections.Concurrent Namespace


TryPeek Method

[image]

.NET Framework Class Library
ConcurrentQueue<(Of <(T>)>)..::.TryPeek Method
ConcurrentQueue<(Of <(T>)>) Class See Also Send Feedback

Attempts to return an object from the beginning of the ConcurrentQueue<(Of <(T>)>) without removing it.

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

Syntax

Visual Basic (Declaration)
Public Function TryPeek ( _
    <OutAttribute> ByRef result As T _
) As Boolean
C#
public bool TryPeek(
    out T result
)

Parameters

result
Type: T %
When this method returns, result contains an object from the beginning of the ConccurrentQueue<(Of <(T>)>) or an unspecified value if the operation failed.

Return Value

true if and object was returned successfully; otherwise, false.

See Also

ConcurrentQueue<(Of <(T>)>) Class
System.Collections.Concurrent Namespace


ConcurrentQueue(T) Properties

[image] [image]

.NET Framework Class Library
ConcurrentQueue<(Of <(T>)>) Properties
ConcurrentQueue<(Of <(T>)>) Class See Also Send Feedback

The ConcurrentQueue<(Of <(T>)>) type exposes the following members.

Properties

Name | Description
Count | Gets the number of elements contained in the ConcurrentQueue<(Of <(T>)>).
IsEmpty | Gets a value that indicates whether the ConcurrentQueue<(Of <(T>)>) is empty.

Explicit Interface Implementations

Name | Description
ICollection..::.IsSynchronized | Gets a value indicating whether access to the ICollection is synchronized with the SyncRoot.
ICollection..::.SyncRoot | Gets an object that can be used to synchronize access to the ICollection. This property is not supported.

See Also

ConcurrentQueue<(Of <(T>)>) Class
System.Collections.Concurrent Namespace


ICollection.IsSynchronized Property

[image]

.NET Framework Class Library
ConcurrentQueue<(Of <(T>)>)..::.ICollection..::.IsSynchronized Property
ConcurrentQueue<(Of <(T>)>) Class See Also Send Feedback

Gets a value indicating whether access to the ICollection is synchronized with the SyncRoot.

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

Syntax

Visual Basic (Declaration)
Private ReadOnly Property IsSynchronized As Boolean
    Implements ICollection.IsSynchronized
C#
bool ICollection.IsSynchronized { get; }

Field Value

true if access to the ICollection is synchronized with the SyncRoot; otherwise, false. For ConcurrentQueue<(Of <(T>)>), this property always returns false.

Implements

ICollection..::.IsSynchronized

See Also

ConcurrentQueue<(Of <(T>)>) Class
System.Collections.Concurrent Namespace


ICollection.SyncRoot Property

[image]

.NET Framework Class Library
ConcurrentQueue<(Of <(T>)>)..::.ICollection..::.SyncRoot Property
ConcurrentQueue<(Of <(T>)>) Class See Also Send Feedback

Gets an object that can be used to synchronize access to the ICollection. This property is not supported.

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

Syntax

Visual Basic (Declaration)
Private ReadOnly Property SyncRoot As Object
    Implements ICollection.SyncRoot
C#
Object ICollection.SyncRoot { get; }

Implements

ICollection..::.SyncRoot

Exceptions

Exception | Condition
System..::.NotSupportedException | The SyncRoot property is not supported.

See Also

ConcurrentQueue<(Of <(T>)>) Class
System.Collections.Concurrent Namespace


Count Property

[image]

.NET Framework Class Library
ConcurrentQueue<(Of <(T>)>)..::.Count Property
ConcurrentQueue<(Of <(T>)>) Class See Also Send Feedback

Gets the number of elements contained in the ConcurrentQueue<(Of <(T>)>).

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

Syntax

Visual Basic (Declaration)
Public ReadOnly Property Count As Integer
C#
public int Count { get; }

Field Value

The number of elements contained in the ConcurrentQueue<(Of <(T>)>).

Implements

ICollection..::.Count

Remarks

For determining whether the collection contains any items, use of the IsEmpty property is recommended rather than retrieving the number of items from the Count property and comparing it to 0.

See Also

ConcurrentQueue<(Of <(T>)>) Class
System.Collections.Concurrent Namespace


IsEmpty Property

[image]

.NET Framework Class Library
ConcurrentQueue<(Of <(T>)>)..::.IsEmpty Property
ConcurrentQueue<(Of <(T>)>) Class See Also Send Feedback

Gets a value that indicates whether the ConcurrentQueue<(Of <(T>)>) is empty.

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

Syntax

Visual Basic (Declaration)
Public ReadOnly Property IsEmpty As Boolean
C#
public bool IsEmpty { get; }

Field Value

true if the ConcurrentQueue<(Of <(T>)>) is empty; otherwise, false.

Remarks

For determining whether the collection contains any items, use of this property is recommended rather than retrieving the number of items from the Count property and comparing it to 0. However, as this collection is intended to be accessed concurrently, it may be the case that another thread will modify the collection after IsEmpty returns, thus invalidating the result.

See Also

ConcurrentQueue<(Of <(T>)>) Class
System.Collections.Concurrent Namespace


ConcurrentStack(T) Class

[image]

.NET Framework Class Library
ConcurrentStack<(Of <(T>)>) Class
See Also Send Feedback

Represents a thread-safe last-in, first-out collection of objects.

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

Syntax

Visual Basic (Declaration)
<SerializableAttribute> _
<HostProtectionAttribute(SecurityAction.LinkDemand, Synchronization := True,  _
    ExternalThreading := True)> _
Public Class ConcurrentStack(Of T) _
    Implements IProducerConsumerCollection(Of T), IEnumerable(Of T),  _
    ICollection, IEnumerable
C#
[SerializableAttribute]
[HostProtectionAttribute(SecurityAction.LinkDemand, Synchronization = true,
    ExternalThreading = true)]
public class ConcurrentStack<T> : IProducerConsumerCollection<T>,
    IEnumerable<T>, ICollection, IEnumerable

Type Parameters

T
Specifies the type of elements in the stack.

Remarks

All public and protected members of ConcurrentStack<(Of <(T>)>) are thread-safe and may be used concurrently from multiple threads.

Inheritance Hierarchy

System..::.Object
System.Collections.Concurrent..::.ConcurrentStack<(Of <(T>)>)

See Also

System.Collections.Concurrent Namespace


ConcurrentStack(T) Constructor

[image] [image]

.NET Framework Class Library
ConcurrentStack<(Of <(T>)>) Constructor
ConcurrentStack<(Of <(T>)>) Class See Also Send Feedback

Overload List

Name | Description
ConcurrentStack<(Of <(T>)>)()()() | Initializes a new instance of the ConcurrentStack<(Of <(T>)>) class.
ConcurrentStack<(Of <(T>)>)(IEnumerable<(Of <(T>)>)) | Initializes a new instance of the ConcurrentStack<(Of <(T>)>) class that contains elements copied from the specified collection

See Also

ConcurrentStack<(Of <(T>)>) Class
System.Collections.Concurrent Namespace


ConcurrentStack(T) Constructor

[image]

.NET Framework Class Library
ConcurrentStack<(Of <(T>)>) Constructor
ConcurrentStack<(Of <(T>)>) Class See Also Send Feedback

Initializes a new instance of the ConcurrentStack<(Of <(T>)>) class.

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

Syntax

Visual Basic (Declaration)
Public Sub New
C#
public ConcurrentStack()

See Also

ConcurrentStack<(Of <(T>)>) Class
ConcurrentStack<(Of <(T>)>) Overload
System.Collections.Concurrent Namespace


ConcurrentStack(T) Constructor (IEnumerable(T))

[image]

.NET Framework Class Library
ConcurrentStack<(Of <(T>)>) Constructor (IEnumerable<(Of <(T>)>))
ConcurrentStack<(Of <(T>)>) Class See Also Send Feedback

Initializes a new instance of the ConcurrentStack<(Of <(T>)>) class that contains elements copied from the specified collection

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

Syntax

Visual Basic (Declaration)
Public Sub New ( _
    collection As IEnumerable(Of T) _
)
C#
public ConcurrentStack(
    IEnumerable<T> collection
)

Parameters

collection
Type: System.Collections.Generic..::.IEnumerable<(Of <( T >)>)
The collection whose elements are copied to the new ConcurrentStack<(Of <(T>)>).

Exceptions

Exception | Condition
System..::.ArgumentNullException | The collection argument is null.

See Also

ConcurrentStack<(Of <(T>)>) Class
ConcurrentStack<(Of <(T>)>) Overload
System.Collections.Concurrent Namespace


ConcurrentStack(T) Methods

[image] [image]

.NET Framework Class Library
ConcurrentStack<(Of <(T>)>) Methods
ConcurrentStack<(Of <(T>)>) Class See Also Send Feedback

The ConcurrentStack<(Of <(T>)>) type exposes the following members.

Methods

Name | Description
Clear | Removes all objects from the ConcurrentStack<(Of <(T>)>).
CopyTo | Copies the ConcurrentStack<(Of <(T>)>) elements to an existing one-dimensional Array, starting at the specified array index.
Equals | (Inherited from Object.)
Finalize | (Inherited from Object.)
GetEnumerator | Returns an enumerator that iterates through the ConcurrentStack<(Of <(T>)>).
GetHashCode | (Inherited from Object.)
GetType | (Inherited from Object.)
MemberwiseClone | (Inherited from Object.)
Push | Inserts an object at the top of the ConcurrentStack<(Of <(T>)>).
PushRange | Overloaded.
ToArray | Copies the items stored in the ConcurrentStack<(Of <(T>)>) to a new array.
ToString | (Inherited from Object.)
TryPeek | Attempts to return an object from the top of the ConcurrentStack<(Of <(T>)>) without removing it.
TryPop | Attempts to pop and return the object at the top of the ConcurrentStack<(Of <(T>)>).
TryPopRange | Overloaded.

Explicit Interface Implementations

Name | Description
ICollection..::.CopyTo | Copies the elements of the ICollection to an Array, starting at a particular Array index.
IEnumerable..::.GetEnumerator | Returns an enumerator that iterates through a collection.
IProducerConsumerCollection<(Of <(T>)>)..::.TryAdd | Attempts to add an object to the IProducerConsumerCollection<(Of <(T>)>).
IProducerConsumerCollection<(Of <(T>)>)..::.TryTake | Attempts to remove and return an object from the IProducerConsumerCollection<(Of <(T>)>).

See Also

ConcurrentStack<(Of <(T>)>) Class
System.Collections.Concurrent Namespace


ICollection.CopyTo Method

[image]

.NET Framework Class Library
ConcurrentStack<(Of <(T>)>)..::.ICollection..::.CopyTo Method
ConcurrentStack<(Of <(T>)>) Class See Also Send Feedback

Copies the elements of the ICollection to an Array, starting at a particular Array index.

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

Syntax

Visual Basic (Declaration)
Private Sub CopyTo ( _
    array As Array, _
    index As Integer _
) Implements ICollection.CopyTo
C#
void ICollection.CopyTo(
    Array array,
    int index
)

Parameters

array
Type: System..::.Array
The one-dimensional Array that is the destination of the elements copied from the ConcurrentStack<(Of <(T>)>). The Array must have zero-based indexing.
index
Type: System..::.Int32
The zero-based index in array at which copying begins.

Implements

ICollection..::.CopyTo(Array, Int32)

Exceptions

Exception | Condition
System..::.ArgumentNullException | array is a null reference (Nothing in Visual Basic).
System..::.ArgumentOutOfRangeException | index is less than zero.
System..::.ArgumentException | array is multidimensional. -or- array does not have zero-based indexing. -or- index is equal to or greater than the length of the array -or- The number of elements in the source ICollection is greater than the available space from index to the end of the destination array. -or- The type of the source ICollection cannot be cast automatically to the type of the destination array.

See Also

ConcurrentStack<(Of <(T>)>) Class
System.Collections.Concurrent Namespace


IEnumerable.GetEnumerator Method

[image]

.NET Framework Class Library
ConcurrentStack<(Of <(T>)>)..::.IEnumerable..::.GetEnumerator Method
ConcurrentStack<(Of <(T>)>) Class See Also Send Feedback

Returns an enumerator that iterates through a collection.

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

Syntax

Visual Basic (Declaration)
Private Function GetEnumerator As IEnumerator
    Implements IEnumerable.GetEnumerator
C#
IEnumerator IEnumerable.GetEnumerator()

Return Value

An IEnumerator that can be used to iterate through the collection.

Implements

IEnumerable..::.GetEnumerator()()()

Remarks

The enumeration represents a moment-in-time snapshot of the contents of the stack. It does not reflect any updates to the collection after GetEnumerator()()() was called. The enumerator is safe to use concurrently with reads from and writes to the stack.

See Also

ConcurrentStack<(Of <(T>)>) Class
System.Collections.Concurrent Namespace


Clear Method

[image]

.NET Framework Class Library
ConcurrentStack<(Of <(T>)>)..::.Clear Method
ConcurrentStack<(Of <(T>)>) Class See Also Send Feedback

Removes all objects from the ConcurrentStack<(Of <(T>)>).

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

Syntax

Visual Basic (Declaration)
Public Sub Clear
C#
public void Clear()

See Also

ConcurrentStack<(Of <(T>)>) Class
System.Collections.Concurrent Namespace


CopyTo Method

[image]

.NET Framework Class Library
ConcurrentStack<(Of <(T>)>)..::.CopyTo Method
ConcurrentStack<(Of <(T>)>) Class See Also Send Feedback

Copies the ConcurrentStack<(Of <(T>)>) elements to an existing one-dimensional Array, starting at the specified array index.

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

Syntax

Visual Basic (Declaration)
Public Sub CopyTo ( _
    array As T(), _
    index As Integer _
)
C#
public void CopyTo(
    T[] array,
    int index
)

Parameters

array
Type: array< T >[]()[]
The one-dimensional Array that is the destination of the elements copied from the ConcurrentStack<(Of <(T>)>). The Array must have zero-based indexing.
index
Type: System..::.Int32
The zero-based index in array at which copying begins.

Implements

IProducerConsumerCollection<(Of <(T>)>)..::.CopyTo(array<T>[]()[], Int32)

Exceptions

Exception | Condition
System..::.ArgumentNullException | array is a null reference (Nothing in Visual Basic).
System..::.ArgumentOutOfRangeException | index is less than zero.
System..::.ArgumentException | index is equal to or greater than the length of the array -or- The number of elements in the source ConcurrentStack<(Of <(T>)>) is greater than the available space from index to the end of the destination array.

See Also

ConcurrentStack<(Of <(T>)>) Class
System.Collections.Concurrent Namespace


GetEnumerator Method

[image]

.NET Framework Class Library
ConcurrentStack<(Of <(T>)>)..::.GetEnumerator Method
ConcurrentStack<(Of <(T>)>) Class See Also Send Feedback

Returns an enumerator that iterates through the ConcurrentStack<(Of <(T>)>).

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

Syntax

Visual Basic (Declaration)
Public Function GetEnumerator As IEnumerator(Of T)
C#
public IEnumerator<T> GetEnumerator()

Return Value

An enumerator for the ConcurrentStack<(Of <(T>)>).

Remarks

The enumeration represents a moment-in-time snapshot of the contents of the stack. It does not reflect any updates to the collection after GetEnumerator()()() was called. The enumerator is safe to use concurrently with reads from and writes to the stack.

See Also

ConcurrentStack<(Of <(T>)>) Class
System.Collections.Concurrent Namespace


IProducerConsumerCollection(T).TryAdd Method

[image]

.NET Framework Class Library
ConcurrentStack<(Of <(T>)>)..::.IProducerConsumerCollection<(Of <(T>)>)..::.TryAdd Method
ConcurrentStack<(Of <(T>)>) Class See Also Send Feedback

Attempts to add an object to the IProducerConsumerCollection<(Of <(T>)>).

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

Syntax

Visual Basic (Declaration)
Private Function TryAdd ( _
    item As T _
) As Boolean Implements IProducerConsumerCollection(Of T).TryAdd
C#
bool IProducerConsumerCollection<T>.TryAdd(
    T item
)

Parameters

item
Type: T
The object to add to the IProducerConsumerCollection<(Of <(T>)>). The value can be a null reference (Nothing in Visual Basic) for reference types.

Return Value

true if the object was added successfully; otherwise, false.

Implements

IProducerConsumerCollection<(Of <(T>)>)..::.TryAdd(T)

Remarks

For ConcurrentStack<(Of <(T>)>), this operation will always insert the object onto the top of the ConcurrentStack<(Of <(T>)>) and return true.

See Also

ConcurrentStack<(Of <(T>)>) Class
System.Collections.Concurrent Namespace


IProducerConsumerCollection(T).TryTake Method

[image]

.NET Framework Class Library
ConcurrentStack<(Of <(T>)>)..::.IProducerConsumerCollection<(Of <(T>)>)..::.TryTake Method
ConcurrentStack<(Of <(T>)>) Class See Also Send Feedback

Attempts to remove and return an object from the IProducerConsumerCollection<(Of <(T>)>).

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

Syntax

Visual Basic (Declaration)
Private Function TryTake ( _
    <OutAttribute> ByRef item As T _
) As Boolean Implements IProducerConsumerCollection(Of T).TryTake
C#
bool IProducerConsumerCollection<T>.TryTake(
    out T item
)

Parameters

item
Type: T %
When this method returns, if the operation was successful, item contains the object removed. If no object was available to be removed, the value is unspecified.

Return Value

true if an element was removed and returned succesfully; otherwise, false.

Implements

IProducerConsumerCollection<(Of <(T>)>)..::.TryTake(T%)

Remarks

For ConcurrentStack<(Of <(T>)>), this operation will attempt to pope the object at the top of the ConcurrentStack<(Of <(T>)>).

See Also

ConcurrentStack<(Of <(T>)>) Class
System.Collections.Concurrent Namespace


Push Method

[image]

.NET Framework Class Library
ConcurrentStack<(Of <(T>)>)..::.Push Method
ConcurrentStack<(Of <(T>)>) Class See Also Send Feedback

Inserts an object at the top of the ConcurrentStack<(Of <(T>)>).

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

Syntax

Visual Basic (Declaration)
Public Sub Push ( _
    item As T _
)
C#
public void Push(
    T item
)

Parameters

item
Type: T
The object to push onto the ConcurrentStack<(Of <(T>)>). The value can be a null reference (Nothing in Visual Basic) for reference types.

See Also

ConcurrentStack<(Of <(T>)>) Class
System.Collections.Concurrent Namespace


PushRange Method

[image] [image]

.NET Framework Class Library
ConcurrentStack<(Of <(T>)>)..::.PushRange Method
ConcurrentStack<(Of <(T>)>) Class See Also Send Feedback

Overload List

Name | Description
PushRange(array<T>[]()[]) | Inserts multiple objects at the top of the ConcurrentStack<(Of <(T>)>) atomically.
PushRange(array<T>[]()[], Int32, Int32) | Inserts multiple objects at the top of the ConcurrentStack<(Of <(T>)>) atomically.

See Also

ConcurrentStack<(Of <(T>)>) Class
System.Collections.Concurrent Namespace


PushRange Method (T[])

[image]

.NET Framework Class Library
ConcurrentStack<(Of <(T>)>)..::.PushRange Method (array<T>[]()[])
ConcurrentStack<(Of <(T>)>) Class See Also Send Feedback

Inserts multiple objects at the top of the ConcurrentStack<(Of <(T>)>) atomically.

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

Syntax

Visual Basic (Declaration)
Public Sub PushRange ( _
    items As T() _
)
C#
public void PushRange(
    T[] items
)

Parameters

items
Type: array< T >[]()[]
The objects to push onto the ConcurrentStack<(Of <(T>)>).

Remarks

When adding multiple items to the stack, using PushRange is a more efficient mechanism than using Push(T) one item at a time. Additionally, PushRange guarantees that all of the elements will be added atomically, meaning that no other threads will be able to inject elements between the elements being pushed. Items at lower indices in the items array will be pushed before items at higher indices.

Exceptions

Exception | Condition
System..::.ArgumentNullException | items is a null reference (Nothing in Visual Basic).

See Also

ConcurrentStack<(Of <(T>)>) Class
PushRange Overload
System.Collections.Concurrent Namespace


PushRange Method (T[], Int32, Int32)

[image]

.NET Framework Class Library
ConcurrentStack<(Of <(T>)>)..::.PushRange Method (array<T>[]()[], Int32, Int32)
ConcurrentStack<(Of <(T>)>) Class See Also Send Feedback

Inserts multiple objects at the top of the ConcurrentStack<(Of <(T>)>) atomically.

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

Syntax

Visual Basic (Declaration)
Public Sub PushRange ( _
    items As T(), _
    startIndex As Integer, _
    count As Integer _
)
C#
public void PushRange(
    T[] items,
    int startIndex,
    int count
)

Parameters

items
Type: array< T >[]()[]
The objects to push onto the ConcurrentStack<(Of <(T>)>).
startIndex
Type: System..::.Int32
The zero-based offset in items at which to begin inserting elements onto the top of the ConcurrentStack<(Of <(T>)>).
count
Type: System..::.Int32
The number of elements to be inserted onto the top of the ConcurrentStack<(Of <(T>)>).

Remarks

When adding multiple items to the stack, using PushRange is a more efficient mechanism than using Push(T) one item at a time. Additionally, PushRange guarantees that all of the elements will be added atomically, meaning that no other threads will be able to inject elements between the elements being pushed. Items at lower indices in the items array will be pushed before items at higher indices.

Exceptions

Exception | Condition
System..::.ArgumentNullException | items is a null reference (Nothing in Visual Basic).
System..::.ArgumentOutOfRangeException | startIndex or count is negative. Or startIndex is greater than or equal to the length of items.
System..::.ArgumentException | startIndex + count is greater than the length of items.

See Also

ConcurrentStack<(Of <(T>)>) Class
PushRange Overload
System.Collections.Concurrent Namespace


ToArray Method

[image]

.NET Framework Class Library
ConcurrentStack<(Of <(T>)>)..::.ToArray Method
ConcurrentStack<(Of <(T>)>) Class See Also Send Feedback

Copies the items stored in the ConcurrentStack<(Of <(T>)>) to a new array.

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

Syntax

Visual Basic (Declaration)
Public Function ToArray As T()
C#
public T[] ToArray()

Return Value

A new array containing a snapshot of elements copied from the ConcurrentStack<(Of <(T>)>).

See Also

ConcurrentStack<(Of <(T>)>) Class
System.Collections.Concurrent Namespace


TryPeek Method

[image]

.NET Framework Class Library
ConcurrentStack<(Of <(T>)>)..::.TryPeek Method
ConcurrentStack<(Of <(T>)>) Class See Also Send Feedback

Attempts to return an object from the top of the ConcurrentStack<(Of <(T>)>) without removing it.

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

Syntax

Visual Basic (Declaration)
Public Function TryPeek ( _
    <OutAttribute> ByRef result As T _
) As Boolean
C#
public bool TryPeek(
    out T result
)

Parameters

result
Type: T %
When this method returns, result contains an object from the top of the ConccurrentStack<(Of <(T>)>) or an unspecified value if the operation failed.

Return Value

true if and object was returned successfully; otherwise, false.

See Also

ConcurrentStack<(Of <(T>)>) Class
System.Collections.Concurrent Namespace


TryPop Method

[image]

.NET Framework Class Library
ConcurrentStack<(Of <(T>)>)..::.TryPop Method
ConcurrentStack<(Of <(T>)>) Class See Also Send Feedback

Attempts to pop and return the object at the top of the ConcurrentStack<(Of <(T>)>).

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

Syntax

Visual Basic (Declaration)
Public Function TryPop ( _
    <OutAttribute> ByRef result As T _
) As Boolean
C#
public bool TryPop(
    out T result
)

Parameters

result
Type: T %
When this method returns, if the operation was successful, result contains the object removed. If no object was available to be removed, the value is unspecified.

Return Value

true if an element was removed and returned from the top of the ConcurrentStack<(Of <(T>)>) succesfully; otherwise, false.

See Also

ConcurrentStack<(Of <(T>)>) Class
System.Collections.Concurrent Namespace


TryPopRange Method

[image] [image]

.NET Framework Class Library
ConcurrentStack<(Of <(T>)>)..::.TryPopRange Method
ConcurrentStack<(Of <(T>)>) Class See Also Send Feedback

Overload List

Name | Description
TryPopRange(array<T>[]()[]) | Attempts to pop and return multiple objects from the top of the ConcurrentStack<(Of <(T>)>) atomically.
TryPopRange(array<T>[]()[], Int32, Int32) | Attempts to pop and return multiple objects from the top of the ConcurrentStack<(Of <(T>)>) atomically.

See Also

ConcurrentStack<(Of <(T>)>) Class
System.Collections.Concurrent Namespace


TryPopRange Method (T[])

[image]

.NET Framework Class Library
ConcurrentStack<(Of <(T>)>)..::.TryPopRange Method (array<T>[]()[])
ConcurrentStack<(Of <(T>)>) Class See Also Send Feedback

Attempts to pop and return multiple objects from the top of the ConcurrentStack<(Of <(T>)>) atomically.

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

Syntax

Visual Basic (Declaration)
Public Function TryPopRange ( _
    items As T() _
) As Integer
C#
public int TryPopRange(
    T[] items
)

Parameters

items
Type: array< T >[]()[]
The Array to which objects popped from the top of the ConcurrentStack<(Of <(T>)>) will be added.

Return Value

The number of objects successfully popped from the top of the ConcurrentStack<(Of <(T>)>) and inserted in items.

Remarks

When popping multiple items, if there is little contention on the stack, using TryPopRange can be more efficient than using TryPop(T%) once per item to be removed. Nodes fill the items with the first node to be popped at the startIndex, the second node to be popped at startIndex + 1, and so on.

Exceptions

Exception | Condition
System..::.ArgumentNullException | items is a null argument (Nothing in Visual Basic).

See Also

ConcurrentStack<(Of <(T>)>) Class
TryPopRange Overload
System.Collections.Concurrent Namespace


TryPopRange Method (T[], Int32, Int32)

[image]

.NET Framework Class Library
ConcurrentStack<(Of <(T>)>)..::.TryPopRange Method (array<T>[]()[], Int32, Int32)
ConcurrentStack<(Of <(T>)>) Class See Also Send Feedback

Attempts to pop and return multiple objects from the top of the ConcurrentStack<(Of <(T>)>) atomically.

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

Syntax

Visual Basic (Declaration)
Public Function TryPopRange ( _
    items As T(), _
    startIndex As Integer, _
    count As Integer _
) As Integer
C#
public int TryPopRange(
    T[] items,
    int startIndex,
    int count
)

Parameters

items
Type: array< T >[]()[]
The Array to which objects popped from the top of the ConcurrentStack<(Of <(T>)>) will be added.
startIndex
Type: System..::.Int32
The zero-based offset in items at which to begin inserting elements from the top of the ConcurrentStack<(Of <(T>)>).
count
Type: System..::.Int32
The number of elements to be popped from top of the ConcurrentStack<(Of <(T>)>) and inserted into items.

Remarks

When popping multiple items, if there is little contention on the stack, using TryPopRange can be more efficient than using TryPop(T%) once per item to be removed. Nodes fill the items with the first node to be popped at the startIndex, the second node to be popped at startIndex + 1, and so on.

Exceptions

Exception | Condition
System..::.ArgumentNullException | items is a null reference (Nothing in Visual Basic).
System..::.ArgumentOutOfRangeException | startIndex or count is negative. Or startIndex is greater than or equal to the length of items.
System..::.ArgumentException | startIndex + count is greater than the length of items.

See Also

ConcurrentStack<(Of <(T>)>) Class
TryPopRange Overload
System.Collections.Concurrent Namespace


ConcurrentStack(T) Properties

[image] [image]

.NET Framework Class Library
ConcurrentStack<(Of <(T>)>) Properties
ConcurrentStack<(Of <(T>)>) Class See Also Send Feedback

The ConcurrentStack<(Of <(T>)>) type exposes the following members.

Properties

Name | Description
Count | Gets the number of elements contained in the ConcurrentStack<(Of <(T>)>).
IsEmpty | Gets a value that indicates whether the ConcurrentStack<(Of <(T>)>) is empty.

Explicit Interface Implementations

Name | Description
ICollection..::.IsSynchronized | Gets a value indicating whether access to the ICollection is synchronized with the SyncRoot.
ICollection..::.SyncRoot | Gets an object that can be used to synchronize access to the ICollection. This property is not supported.

See Also

ConcurrentStack<(Of <(T>)>) Class
System.Collections.Concurrent Namespace


ICollection.IsSynchronized Property

[image]

.NET Framework Class Library
ConcurrentStack<(Of <(T>)>)..::.ICollection..::.IsSynchronized Property
ConcurrentStack<(Of <(T>)>) Class See Also Send Feedback

Gets a value indicating whether access to the ICollection is synchronized with the SyncRoot.

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

Syntax

Visual Basic (Declaration)
Private ReadOnly Property IsSynchronized As Boolean
    Implements ICollection.IsSynchronized
C#
bool ICollection.IsSynchronized { get; }

Field Value

true if access to the ICollection is synchronized with the SyncRoot; otherwise, false. For ConcurrentStack<(Of <(T>)>), this property always returns false.

Implements

ICollection..::.IsSynchronized

See Also

ConcurrentStack<(Of <(T>)>) Class
System.Collections.Concurrent Namespace


ICollection.SyncRoot Property

[image]

.NET Framework Class Library
ConcurrentStack<(Of <(T>)>)..::.ICollection..::.SyncRoot Property
ConcurrentStack<(Of <(T>)>) Class See Also Send Feedback

Gets an object that can be used to synchronize access to the ICollection. This property is not supported.

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

Syntax

Visual Basic (Declaration)
Private ReadOnly Property SyncRoot As Object
    Implements ICollection.SyncRoot
C#
Object ICollection.SyncRoot { get; }

Implements

ICollection..::.SyncRoot

Exceptions

Exception | Condition
System..::.NotSupportedException | The SyncRoot property is not supported

See Also

ConcurrentStack<(Of <(T>)>) Class
System.Collections.Concurrent Namespace


Count Property

[image]

.NET Framework Class Library
ConcurrentStack<(Of <(T>)>)..::.Count Property
ConcurrentStack<(Of <(T>)>) Class See Also Send Feedback

Gets the number of elements contained in the ConcurrentStack<(Of <(T>)>).

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

Syntax

Visual Basic (Declaration)
Public ReadOnly Property Count As Integer
C#
public int Count { get; }

Field Value

The number of elements contained in the ConcurrentStack<(Of <(T>)>).

Implements

ICollection..::.Count

Remarks

For determining whether the collection contains any items, use of the IsEmpty property is recommended rather than retrieving the number of items from the Count property and comparing it to 0.

See Also

ConcurrentStack<(Of <(T>)>) Class
System.Collections.Concurrent Namespace


IsEmpty Property

[image]

.NET Framework Class Library
ConcurrentStack<(Of <(T>)>)..::.IsEmpty Property
ConcurrentStack<(Of <(T>)>) Class See Also Send Feedback

Gets a value that indicates whether the ConcurrentStack<(Of <(T>)>) is empty.

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

Syntax

Visual Basic (Declaration)
Public ReadOnly Property IsEmpty As Boolean
C#
public bool IsEmpty { get; }

Field Value

true if the ConcurrentStack<(Of <(T>)>) is empty; otherwise, false.

Remarks

For determining whether the collection contains any items, use of this property is recommended rather than retrieving the number of items from the Count property and comparing it to 0. However, as this collection is intended to be accessed concurrently, it may be the case that another thread will modify the collection after IsEmpty returns, thus invalidating the result.

See Also

ConcurrentStack<(Of <(T>)>) Class
System.Collections.Concurrent Namespace


IProducerConsumerCollection(T) Interface

[image]

.NET Framework Class Library
IProducerConsumerCollection<(Of <(T>)>) Interface
See Also Send Feedback

Defines methods to manipulate thread-safe collections intended for producer/consumer usage.

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

Syntax

Visual Basic (Declaration)
Public Interface IProducerConsumerCollection(Of T) _
    Implements IEnumerable(Of T), ICollection, IEnumerable
C#
public interface IProducerConsumerCollection<T> : IEnumerable<T>,
    ICollection, IEnumerable

Type Parameters

T
Specifies the type of elements in the collection.

Remarks

All implementations of this interface must enable all members of this interface to be used concurrently from multiple threads.

See Also

System.Collections.Concurrent Namespace


IProducerConsumerCollection(T) Methods

[image] [image]

.NET Framework Class Library
IProducerConsumerCollection<(Of <(T>)>) Methods
IProducerConsumerCollection<(Of <(T>)>) Interface See Also Send Feedback

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

Methods

Name | Description
CopyTo | Overloaded.
GetEnumerator | Overloaded.
ToArray | Copies the elements contained in the IProducerConsumerCollection<(Of <(T>)>) to a new array.
TryAdd | Attempts to add an object to the IProducerConsumerCollection<(Of <(T>)>).
TryTake | Attempts to remove and return an object from the IProducerConsumerCollection<(Of <(T>)>).

See Also

IProducerConsumerCollection<(Of <(T>)>) Interface
System.Collections.Concurrent Namespace


CopyTo Method

[image] [image]

.NET Framework Class Library
IProducerConsumerCollection<(Of <(T>)>)..::.CopyTo Method
IProducerConsumerCollection<(Of <(T>)>) Interface See Also Send Feedback

Overload List

Name | Description
CopyTo(Array, Int32) | (Inherited from ICollection.)
CopyTo(array<T>[]()[], Int32) | Copies the elements of the IProducerConsumerCollection<(Of <(T>)>) to an Array, starting at a specified index.

See Also

IProducerConsumerCollection<(Of <(T>)>) Interface
System.Collections.Concurrent Namespace


CopyTo Method (T[], Int32)

[image]

.NET Framework Class Library
IProducerConsumerCollection<(Of <(T>)>)..::.CopyTo Method (array<T>[]()[], Int32)
IProducerConsumerCollection<(Of <(T>)>) Interface See Also Send Feedback

Copies the elements of the IProducerConsumerCollection<(Of <(T>)>) to an Array, starting at a specified index.

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

Syntax

Visual Basic (Declaration)
Sub CopyTo ( _
    array As T(), _
    index As Integer _
)
C#
void CopyTo(
    T[] array,
    int index
)

Parameters

array
Type: array< T >[]()[]
The one-dimensional Array that is the destination of the elements copied from the IProducerConsumerCollection<(Of <(T>)>). The array must have zero-based indexing.
index
Type: System..::.Int32
The zero-based index in array at which copying begins.

Exceptions

Exception | Condition
System..::.ArgumentNullException | array is a null reference (Nothing in Visual Basic).
System..::.ArgumentOutOfRangeException | index is less than zero.
System..::.ArgumentException | index is equal to or greater than the length of the array -or- The number of elements in the source ConcurrentQueue<(Of <(T>)>) is greater than the available space from index to the end of the destination array.

See Also

IProducerConsumerCollection<(Of <(T>)>) Interface
CopyTo Overload
System.Collections.Concurrent Namespace


GetEnumerator Method

[image] [image]

.NET Framework Class Library
IProducerConsumerCollection<(Of <(T>)>)..::.GetEnumerator Method
IProducerConsumerCollection<(Of <(T>)>) Interface See Also Send Feedback

Overload List

Name | Description
GetEnumerator()()() | (Inherited from IEnumerable<(Of <( T >)>).)
GetEnumerator()()() | (Inherited from IEnumerable.)

See Also

IProducerConsumerCollection<(Of <(T>)>) Interface
System.Collections.Concurrent Namespace


ToArray Method

[image]

.NET Framework Class Library
IProducerConsumerCollection<(Of <(T>)>)..::.ToArray Method
IProducerConsumerCollection<(Of <(T>)>) Interface See Also Send Feedback

Copies the elements contained in the IProducerConsumerCollection<(Of <(T>)>) to a new array.

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

Syntax

Visual Basic (Declaration)
Function ToArray As T()
C#
T[] ToArray()

Return Value

A new array containing the elements copied from the IProducerConsumerCollection<(Of <(T>)>).

See Also

IProducerConsumerCollection<(Of <(T>)>) Interface
System.Collections.Concurrent Namespace


TryAdd Method

[image]

.NET Framework Class Library
IProducerConsumerCollection<(Of <(T>)>)..::.TryAdd Method
IProducerConsumerCollection<(Of <(T>)>) Interface See Also Send Feedback

Attempts to add an object to the IProducerConsumerCollection<(Of <(T>)>).

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

Syntax

Visual Basic (Declaration)
Function TryAdd ( _
    item As T _
) As Boolean
C#
bool TryAdd(
    T item
)

Parameters

item
Type: T
The object to add to the IProducerConsumerCollection<(Of <(T>)>).

Return Value

true if the object was added successfully; otherwise, false.

Exceptions

Exception | Condition
System..::.ArgumentException | The item was invalid for this collection.

See Also

IProducerConsumerCollection<(Of <(T>)>) Interface
System.Collections.Concurrent Namespace


TryTake Method

[image]

.NET Framework Class Library
IProducerConsumerCollection<(Of <(T>)>)..::.TryTake Method
IProducerConsumerCollection<(Of <(T>)>) Interface See Also Send Feedback

Attempts to remove and return an object from the IProducerConsumerCollection<(Of <(T>)>).

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

Syntax

Visual Basic (Declaration)
Function TryTake ( _
    <OutAttribute> ByRef item As T _
) As Boolean
C#
bool TryTake(
    out T item
)

Parameters

item
Type: T %
When this method returns, if the object was removed and returned successfully, item contains the removed object. If no object was available to be removed, the value is unspecified.

Return Value

true if an object was removed and returned successfully; otherwise, false.

See Also

IProducerConsumerCollection<(Of <(T>)>) Interface
System.Collections.Concurrent Namespace


IProducerConsumerCollection(T) Properties

[image] [image]

.NET Framework Class Library
IProducerConsumerCollection<(Of <(T>)>) Properties
IProducerConsumerCollection<(Of <(T>)>) Interface See Also Send Feedback

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

Properties

Name | Description
Count | (Inherited from ICollection.)
IsSynchronized | (Inherited from ICollection.)
SyncRoot | (Inherited from ICollection.)

See Also

IProducerConsumerCollection<(Of <(T>)>) Interface
System.Collections.Concurrent Namespace


OrderablePartitioner(TSource) Class

[image]

.NET Framework Class Library
OrderablePartitioner<(Of <(TSource>)>) Class
See Also Send Feedback

Represents a particular manner of splitting an orderable data source into multiple partitions.

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

Syntax

Visual Basic (Declaration)
<HostProtectionAttribute(SecurityAction.LinkDemand, Synchronization := True,  _
    ExternalThreading := True)> _
Public MustInherit Class OrderablePartitioner(Of TSource) _
    Inherits Partitioner(Of TSource)
C#
[HostProtectionAttribute(SecurityAction.LinkDemand, Synchronization = true,
    ExternalThreading = true)]
public abstract class OrderablePartitioner<TSource> : Partitioner<TSource>

Type Parameters

TSource
Type of the elements in the collection.

Remarks

Each element in each partition has an integer index associated with it, which determines the relative order of that element against elements in other partitions.

Inheritors of OrderablePartitioner<(Of <(TSource>)>) must adhere to the following rules:

  1. All indices must be unique, such that there may not be duplicate indices. If all indices are not unique, the output ordering may be scrambled.
  2. All indices must be non-negative. If any indices are negative, consumers of the implementation may throw exceptions.
  3. GetPartitions(Int32) and GetOrderablePartitions(Int32) should throw a ArgumentOutOfRangeException if the requested partition count is less than or equal to zero.
  4. GetPartitions(Int32) and GetOrderablePartitions(Int32) should always return a number of enumerables equal to the requested partition count. If the partitioner runs out of data and cannot create as many partitions as requested, an empty enumerator should be returned for each of the remaining partitions. If this rule is not followed, consumers of the implementation may throw a InvalidOperationException.
  5. GetPartitions(Int32), GetOrderablePartitions(Int32), GetDynamicPartitions()()(), and GetOrderableDynamicPartitions()()() should never return null. If null is returned, a consumer of the implementation may throw a InvalidOperationException.
  6. GetPartitions(Int32), GetOrderablePartitions(Int32), GetDynamicPartitions()()(), and GetOrderableDynamicPartitions()()() should always return partitions that can fully and uniquely enumerate the input data source. All of the data and only the data contained in the input source should be enumerated, with no duplication that was not already in the input, unless specifically required by the particular partitioner's design. If this is not followed, the output ordering may be scrambled.
  7. If KeysOrderedInEachPartition returns true, each partition must return elements with increasing key indices.
  8. If KeysOrderedAcrossPartitions returns true, all the keys in partition numbered N must be larger than all the keys in partition numbered N-1.
  9. If KeysNormalized returns true, all indices must be monotonically increasing from 0, though not necessarily within a single partition.

Inheritance Hierarchy

System..::.Object
System.Collections.Concurrent..::.Partitioner <(Of <(TSource>)>)
System.Collections.Concurrent..::.OrderablePartitioner<(Of <(TSource>)>)

See Also

System.Collections.Concurrent Namespace


OrderablePartitioner(TSource) Constructor

[image]

.NET Framework Class Library
OrderablePartitioner<(Of <(TSource>)>) Constructor
OrderablePartitioner<(Of <(TSource>)>) Class See Also Send Feedback

Initializes a new instance of the OrderablePartitioner<(Of <(TSource>)>) class with the specified constraints on the index keys.

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

Syntax

Visual Basic (Declaration)
Protected Sub New ( _
    keysOrderedInEachPartition As Boolean, _
    keysOrderedAcrossPartitions As Boolean, _
    keysNormalized As Boolean _
)
C#
protected OrderablePartitioner(
    bool keysOrderedInEachPartition,
    bool keysOrderedAcrossPartitions,
    bool keysNormalized
)

Parameters

keysOrderedInEachPartition
Type: System..::.Boolean
Indicates whether the elements in each partition are yielded in the order of increasing keys.
keysOrderedAcrossPartitions
Type: System..::.Boolean
Indicates whether elements in an earlier partition always come before elements in a later partition. If true, each element in partition 0 has a smaller order key than any element in partition 1, each element in partition 1 has a smaller order key than any element in partition 2, and so on.
keysNormalized
Type: System..::.Boolean
Indicates whether keys are normalized. If true, all order keys are distinct integers in the range [0 .. numberOfElements-1]. If false, order keys must still be dictinct, but only their relative order is considered, not their absolute values.

See Also

OrderablePartitioner<(Of <(TSource>)>) Class
System.Collections.Concurrent Namespace


OrderablePartitioner(TSource) Methods

[image] [image]

.NET Framework Class Library
OrderablePartitioner<(Of <(TSource>)>) Methods
OrderablePartitioner<(Of <(TSource>)>) Class See Also Send Feedback

The OrderablePartitioner<(Of <(TSource>)>) type exposes the following members.

Methods

Name | Description
Equals | (Inherited from Object.)
Finalize | (Inherited from Object.)
GetDynamicPartitions | Creates an object that can partition the underlying collection into a variable number of partitions. (Overrides Partitioner<(Of <(TSource>)>)..::.GetDynamicPartitions()()().)
GetHashCode | (Inherited from Object.)
GetOrderableDynamicPartitions | Creates an object that can partition the underlying collection into a variable number of partitions.
GetOrderablePartitions | Partitions the underlying collection into the specified number of orderable partitions.
GetPartitions | Partitions the underlying collection into the given number of ordered partitions. (Overrides Partitioner<(Of <(TSource>)>)..::.GetPartitions(Int32).)
GetType | (Inherited from Object.)
MemberwiseClone | (Inherited from Object.)
ToString | (Inherited from Object.)

See Also

OrderablePartitioner<(Of <(TSource>)>) Class
System.Collections.Concurrent Namespace


GetDynamicPartitions Method

[image]

.NET Framework Class Library
OrderablePartitioner<(Of <(TSource>)>)..::.GetDynamicPartitions Method
OrderablePartitioner<(Of <(TSource>)>) Class See Also Send Feedback

Creates an object that can partition the underlying collection into a variable number of partitions.

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

Syntax

Visual Basic (Declaration)
Public Overrides Function GetDynamicPartitions As IEnumerable(Of TSource)
C#
public override IEnumerable<TSource> GetDynamicPartitions()

Return Value

An object that can create partitions over the underlying data source.

Remarks

The returned object implements the IEnumerable<(Of <(TSource>)>) interface. Calling GetEnumerator on the object creates another partition over the sequence.

The default implementation provides the same behavior as GetOrderableDynamicPartitions()()() except that the returned set of partitions does not provide the keys for the elements.

The GetDynamicPartitions()()() method is only supported if the SupportsDynamicPartitions property returns true.

Exceptions

Exception | Condition
System..::.NotSupportedException | Dynamic partitioning is not supported by this partitioner.

See Also

OrderablePartitioner<(Of <(TSource>)>) Class
System.Collections.Concurrent Namespace


GetOrderableDynamicPartitions Method

[image]

.NET Framework Class Library
OrderablePartitioner<(Of <(TSource>)>)..::.GetOrderableDynamicPartitions Method
OrderablePartitioner<(Of <(TSource>)>) Class See Also Send Feedback

Creates an object that can partition the underlying collection into a variable number of partitions.

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

Syntax

Visual Basic (Declaration)
Public Overridable Function GetOrderableDynamicPartitions As IEnumerable(Of KeyValuePair(Of Long, TSource))
C#
public virtual IEnumerable<KeyValuePair<long, TSource>> GetOrderableDynamicPartitions()

Return Value

An object that can create partitions over the underlying data source.

Remarks

The returned object implements the IEnumerable<(Of <(TSource>)>) interface. Calling GetEnumerator on the object creates another partition over the sequence.

Each partition is represented as an enumerator over key-value pairs. The value in the pair is the element itself, and the key is an integer which determines the relative ordering of this element against other elements.

The GetOrderableDynamicPartitions()()() method is only supported if the SupportsDynamicPartitions property returns true.

Exceptions

Exception | Condition
System..::.NotSupportedException | Dynamic partitioning is not supported by this partitioner.

See Also

OrderablePartitioner<(Of <(TSource>)>) Class
System.Collections.Concurrent Namespace


GetOrderablePartitions Method

[image]

.NET Framework Class Library
OrderablePartitioner<(Of <(TSource>)>)..::.GetOrderablePartitions Method
OrderablePartitioner<(Of <(TSource>)>) Class See Also Send Feedback

Partitions the underlying collection into the specified number of orderable partitions.

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

Syntax

Visual Basic (Declaration)
Public MustOverride Function GetOrderablePartitions ( _
    partitionCount As Integer _
) As IList(Of IEnumerator(Of KeyValuePair(Of Long, TSource)))
C#
public abstract IList<IEnumerator<KeyValuePair<long, TSource>>> GetOrderablePartitions(
    int partitionCount
)

Parameters

partitionCount
Type: System..::.Int32
The number of partitions to create.

Return Value

A list containing partitionCount enumerators.

Remarks

Each partition is represented as an enumerator over key-value pairs. The value of the pair is the element itself, and the key is an integer which determines the relative ordering of this element against other elements in the data source.

See Also

OrderablePartitioner<(Of <(TSource>)>) Class
System.Collections.Concurrent Namespace


GetPartitions Method

[image]

.NET Framework Class Library
OrderablePartitioner<(Of <(TSource>)>)..::.GetPartitions Method
OrderablePartitioner<(Of <(TSource>)>) Class See Also Send Feedback

Partitions the underlying collection into the given number of ordered partitions.

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

Syntax

Visual Basic (Declaration)
Public Overrides Function GetPartitions ( _
    partitionCount As Integer _
) As IList(Of IEnumerator(Of TSource))
C#
public override IList<IEnumerator<TSource>> GetPartitions(
    int partitionCount
)

Parameters

partitionCount
Type: System..::.Int32
The number of partitions to create.

Return Value

A list containing partitionCount enumerators.

Remarks

The default implementation provides the same behavior as GetOrderablePartitions(Int32) except that the returned set of partitions does not provide the keys for the elements.

See Also

OrderablePartitioner<(Of <(TSource>)>) Class
System.Collections.Concurrent Namespace


OrderablePartitioner(TSource) Properties

[image] [image]

.NET Framework Class Library
OrderablePartitioner<(Of <(TSource>)>) Properties
OrderablePartitioner<(Of <(TSource>)>) Class See Also Send Feedback

The OrderablePartitioner<(Of <(TSource>)>) type exposes the following members.

Properties

Name | Description
KeysNormalized | Gets whether order keys are normalized.
KeysOrderedAcrossPartitions | Gets whether elements in an earlier partition always come before elements in a later partition.
KeysOrderedInEachPartition | Gets whether elements in each partition are yielded in the order of increasing keys.
SupportsDynamicPartitions | Gets whether additional partitions can be created dynamically. (Inherited from Partitioner<(Of <(TSource>)>).)

See Also

OrderablePartitioner<(Of <(TSource>)>) Class
System.Collections.Concurrent Namespace


KeysNormalized Property

[image]

.NET Framework Class Library
OrderablePartitioner<(Of <(TSource>)>)..::.KeysNormalized Property
OrderablePartitioner<(Of <(TSource>)>) Class See Also Send Feedback

Gets whether order keys are normalized.

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

Syntax

Visual Basic (Declaration)
Public Property KeysNormalized As Boolean
C#
public bool KeysNormalized { get; private set; }

Remarks

If KeysNormalized returns true, all order keys are distinct integers in the range [0 .. numberOfElements-1]. If the property returns false, order keys must still be dictinct, but only their relative order is considered, not their absolute values.

See Also

OrderablePartitioner<(Of <(TSource>)>) Class
System.Collections.Concurrent Namespace


KeysOrderedAcrossPartitions Property

[image]

.NET Framework Class Library
OrderablePartitioner<(Of <(TSource>)>)..::.KeysOrderedAcrossPartitions Property
OrderablePartitioner<(Of <(TSource>)>) Class See Also Send Feedback

Gets whether elements in an earlier partition always come before elements in a later partition.

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

Syntax

Visual Basic (Declaration)
Public Property KeysOrderedAcrossPartitions As Boolean
C#
public bool KeysOrderedAcrossPartitions { get; private set; }

Remarks

If KeysOrderedAcrossPartitions returns true, each element in partition 0 has a smaller order key than any element in partition 1, each element in partition 1 has a smaller order key than any element in partition 2, and so on.

See Also

OrderablePartitioner<(Of <(TSource>)>) Class
System.Collections.Concurrent Namespace


KeysOrderedInEachPartition Property

[image]

.NET Framework Class Library
OrderablePartitioner<(Of <(TSource>)>)..::.KeysOrderedInEachPartition Property
OrderablePartitioner<(Of <(TSource>)>) Class See Also Send Feedback

Gets whether elements in each partition are yielded in the order of increasing keys.

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

Syntax

Visual Basic (Declaration)
Public Property KeysOrderedInEachPartition As Boolean
C#
public bool KeysOrderedInEachPartition { get; private set; }

See Also

OrderablePartitioner<(Of <(TSource>)>) Class
System.Collections.Concurrent Namespace


Partitioner Class

[image]

.NET Framework Class Library
Partitioner Class
See Also Send Feedback

Provides common partitioning strategies for arrays, lists, and enumerables.

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

Syntax

Visual Basic (Declaration)
<HostProtectionAttribute(SecurityAction.LinkDemand, Synchronization := True,  _
    ExternalThreading := True)> _
Public NotInheritable Class Partitioner
C#
[HostProtectionAttribute(SecurityAction.LinkDemand, Synchronization = true,
    ExternalThreading = true)]
public static class Partitioner

Remarks

The static methods on Partitioner are all thread-safe and may be used concurrently from multiple threads. However, while a created partitioner is in use, the underlying data source should not be modified, whether from the same thread that's using a partitioner or from a separate thread.

Inheritance Hierarchy

System..::.Object
System.Collections.Concurrent..::.Partitioner

See Also

System.Collections.Concurrent Namespace


Partitioner Methods

[image] [image]

.NET Framework Class Library
Partitioner Methods
Partitioner Class See Also Send Feedback

Methods

Name | Description
Create | Overloaded.

See Also

Partitioner Class
System.Collections.Concurrent Namespace


Create Method

[image] [image]

.NET Framework Class Library
Partitioner..::.Create Method
Partitioner Class See Also Send Feedback

Overload List

Name | Description
Create<(Of <(TSource>)>)(IEnumerable<(Of <(TSource>)>)) | Creates an orderable partitioner from a IEnumerable<(Of <(T>)>) instance.
Create<(Of <(TSource>)>)(IList<(Of <(TSource>)>), Boolean) | Creates an orderable partitioner from an IList<(Of <(T>)>) instance.
Create<(Of <(TSource>)>)(array<TSource>[]()[], Boolean) | Creates an orderable partitioner from a Array instance.

See Also

Partitioner Class
System.Collections.Concurrent Namespace


Create(TSource) Method (IEnumerable(TSource))

[image]

.NET Framework Class Library
Partitioner..::.Create<(Of <(TSource>)>) Method (IEnumerable<(Of <(TSource>)>))
Partitioner Class See Also Send Feedback

Creates an orderable partitioner from a IEnumerable<(Of <(T>)>) instance.

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

Syntax

Visual Basic (Declaration)
Public Shared Function Create(Of TSource) ( _
    source As IEnumerable(Of TSource) _
) As OrderablePartitioner(Of TSource)
C#
public static OrderablePartitioner<TSource> Create<TSource>(
    IEnumerable<TSource> source
)

Parameters

source
Type: System.Collections.Generic..::.IEnumerable<(Of <(TSource>)>)
The enumerable to be partitioned.

Type Parameters

TSource
Type of the elements in source enumerable.

Return Value

An orderable partitioner based on the input array.

Remarks

The ordering used in the created partitioner is determined by the natural order of the elements as retrieved from the source enumerable.

See Also

Partitioner Class
Create Overload
System.Collections.Concurrent Namespace


Create(TSource) Method (IList(TSource), Boolean)

[image]

.NET Framework Class Library
Partitioner..::.Create<(Of <(TSource>)>) Method (IList<(Of <(TSource>)>), Boolean)
Partitioner Class See Also Send Feedback

Creates an orderable partitioner from an IList<(Of <(T>)>) instance.

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

Syntax

Visual Basic (Declaration)
Public Shared Function Create(Of TSource) ( _
    list As IList(Of TSource), _
    loadBalance As Boolean _
) As OrderablePartitioner(Of TSource)
C#
public static OrderablePartitioner<TSource> Create<TSource>(
    IList<TSource> list,
    bool loadBalance
)

Parameters

list
Type: System.Collections.Generic..::.IList<(Of <(TSource>)>)
The list to be partitioned.
loadBalance
Type: System..::.Boolean
A Boolean value that indicates whether the created partitioner should dynamically load balance between partitions rather than statically partition.

Type Parameters

TSource
Type of the elements in source list.

Return Value

An orderable partitioner based on the input list.

See Also

Partitioner Class
Create Overload
System.Collections.Concurrent Namespace


Create(TSource) Method (TSource[], Boolean)

[image]

.NET Framework Class Library
Partitioner..::.Create<(Of <(TSource>)>) Method (array<TSource>[]()[], Boolean)
Partitioner Class See Also Send Feedback

Creates an orderable partitioner from a Array instance.

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

Syntax

Visual Basic (Declaration)
Public Shared Function Create(Of TSource) ( _
    array As TSource(), _
    loadBalance As Boolean _
) As OrderablePartitioner(Of TSource)
C#
public static OrderablePartitioner<TSource> Create<TSource>(
    TSource[] array,
    bool loadBalance
)

Parameters

array
Type: array< TSource >[]()[]
The array to be partitioned.
loadBalance
Type: System..::.Boolean
A Boolean value that indicates whether the created partitioner should dynamically load balance between partitions rather than statically partition.

Type Parameters

TSource
Type of the elements in source array.

Return Value

An orderable partitioner based on the input array.

See Also

Partitioner Class
Create Overload
System.Collections.Concurrent Namespace


Partitioner(TSource) Class

[image]

.NET Framework Class Library
Partitioner<(Of <(TSource>)>) Class
See Also Send Feedback

Represents a particular manner of splitting a data source into multiple partitions.

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

Syntax

Visual Basic (Declaration)
<HostProtectionAttribute(SecurityAction.LinkDemand, Synchronization := True,  _
    ExternalThreading := True)> _
Public MustInherit Class Partitioner(Of TSource)
C#
[HostProtectionAttribute(SecurityAction.LinkDemand, Synchronization = true,
    ExternalThreading = true)]
public abstract class Partitioner<TSource>

Type Parameters

TSource
Type of the elements in the collection.

Remarks

Inheritors of Partitioner<(Of <(TSource>)>) must adhere to the following rules:

  1. GetPartitions(Int32) should throw a ArgumentOutOfRangeException if the requested partition count is less than or equal to zero.
  2. GetPartitions(Int32) should always return a number of enumerables equal to the requested partition count. If the partitioner runs out of data and cannot create as many partitions as requested, an empty enumerator should be returned for each of the remaining partitions. If this rule is not followed, consumers of the implementation may throw a InvalidOperationException.
  3. GetPartitions(Int32) and GetDynamicPartitions()()() should never return null. If null is returned, a consumer of the implementation may throw a InvalidOperationException.
  4. GetPartitions(Int32) and GetDynamicPartitions()()() should always return partitions that can fully and uniquely enumerate the input data source. All of the data and only the data contained in the input source should be enumerated, with no duplication that was not already in the input, unless specifically required by the particular partitioner's design. If this is not followed, the output ordering may be scrambled.

Inheritance Hierarchy

System..::.Object
System.Collections.Concurrent..::.Partitioner<(Of <(TSource>)>)
System.Collections.Concurrent..::.OrderablePartitioner<(Of <(TSource>)>)

See Also

System.Collections.Concurrent Namespace


Partitioner(TSource) Constructor

[image]

.NET Framework Class Library
Partitioner<(Of <(TSource>)>) Constructor
Partitioner<(Of <(TSource>)>) Class See Also Send Feedback

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

Syntax

Visual Basic (Declaration)
Protected Sub New
C#
protected Partitioner()

See Also

Partitioner<(Of <(TSource>)>) Class
System.Collections.Concurrent Namespace


Partitioner(TSource) Methods

[image] [image]

.NET Framework Class Library
Partitioner<(Of <(TSource>)>) Methods
Partitioner<(Of <(TSource>)>) Class See Also Send Feedback

The Partitioner<(Of <(TSource>)>) type exposes the following members.

Methods

Name | Description
Equals | (Inherited from Object.)
Finalize | (Inherited from Object.)
GetDynamicPartitions | Creates an object that can partition the underlying collection into a variable number of partitions.
GetHashCode | (Inherited from Object.)
GetPartitions | Partitions the underlying collection into the given number of partitions.
GetType | (Inherited from Object.)
MemberwiseClone | (Inherited from Object.)
ToString | (Inherited from Object.)

See Also

Partitioner<(Of <(TSource>)>) Class
System.Collections.Concurrent Namespace


GetDynamicPartitions Method

[image]

.NET Framework Class Library
Partitioner<(Of <(TSource>)>)..::.GetDynamicPartitions Method
Partitioner<(Of <(TSource>)>) Class See Also Send Feedback

Creates an object that can partition the underlying collection into a variable number of partitions.

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

Syntax

Visual Basic (Declaration)
Public Overridable Function GetDynamicPartitions As IEnumerable(Of TSource)
C#
public virtual IEnumerable<TSource> GetDynamicPartitions()

Return Value

An object that can create partitions over the underlying data source.

Remarks

The returned object implements the IEnumerable<(Of <(TSource>)>) interface. Calling GetEnumerator on the object creates another partition over the sequence.

The GetDynamicPartitions()()() method is only supported if the SupportsDynamicPartitions property returns true.

Exceptions

Exception | Condition
System..::.NotSupportedException | Dynamic partitioning is not supported by this partitioner.

See Also

Partitioner<(Of <(TSource>)>) Class
System.Collections.Concurrent Namespace


GetPartitions Method

[image]

.NET Framework Class Library
Partitioner<(Of <(TSource>)>)..::.GetPartitions Method
Partitioner<(Of <(TSource>)>) Class See Also Send Feedback

Partitions the underlying collection into the given number of partitions.

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

Syntax

Visual Basic (Declaration)
Public MustOverride Function GetPartitions ( _
    partitionCount As Integer _
) As IList(Of IEnumerator(Of TSource))
C#
public abstract IList<IEnumerator<TSource>> GetPartitions(
    int partitionCount
)

Parameters

partitionCount
Type: System..::.Int32
The number of partitions to create.

Return Value

A list containing partitionCount enumerators.

See Also

Partitioner<(Of <(TSource>)>) Class
System.Collections.Concurrent Namespace


Partitioner(TSource) Properties

[image] [image]

.NET Framework Class Library
Partitioner<(Of <(TSource>)>) Properties
Partitioner<(Of <(TSource>)>) Class See Also Send Feedback

The Partitioner<(Of <(TSource>)>) type exposes the following members.

Properties

Name | Description
SupportsDynamicPartitions | Gets whether additional partitions can be created dynamically.

See Also

Partitioner<(Of <(TSource>)>) Class
System.Collections.Concurrent Namespace


SupportsDynamicPartitions Property

[image]

.NET Framework Class Library
Partitioner<(Of <(TSource>)>)..::.SupportsDynamicPartitions Property
Partitioner<(Of <(TSource>)>) Class See Also Send Feedback

Gets whether additional partitions can be created dynamically.

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

Syntax

Visual Basic (Declaration)
Public Overridable ReadOnly Property SupportsDynamicPartitions As Boolean
C#
public virtual bool SupportsDynamicPartitions { get; }

Return Value

true if the Partitioner<(Of <(TSource>)>) can create partitions dynamically as they are requested; false if the Partitioner<(Of <(TSource>)>) can only allocate partitions statically.

Remarks

If a derived class does not override and implement GetDynamicPartitions()()(), SupportsDynamicPartitions should return false. The value of SupportsDynamicPartitions should not vary over the lifetime of this instance.

See Also

Partitioner<(Of <(TSource>)>) Class
System.Collections.Concurrent Namespace


System.Linq Namespace

[image]

.NET Framework Class Library
System.Linq Namespace
Send Feedback

Classes

Class | Description
OrderedParallelQuery<(Of <(TSource>)>) | Represents a sorted, parallel sequence.
ParallelEnumerable | Provides a set of methods for querying objects that implement ParallelQuery{TSource}. This is the parallel equivalent of Enumerable.
ParallelQuery | Represents a parallel sequence.
ParallelQuery<(Of <(TSource>)>) | Represents a parallel sequence.

Enumerations

Enumeration | Description
ParallelExecutionMode | The query execution mode is a hint that specifies how the system should handle performance trade-offs when parallelizing queries.
ParallelMergeOptions | Specifies the preferred type of output merge to use in a query. This is a hint only, and may not be respected by the system when parallelizing all queries.


OrderedParallelQuery(TSource) Class

[image]

.NET Framework Class Library
OrderedParallelQuery<(Of <(TSource>)>) Class
See Also Send Feedback

Represents a sorted, parallel sequence.

Namespace: System.Linq
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Class OrderedParallelQuery(Of TSource) _
    Inherits ParallelQuery(Of T)
C#
public class OrderedParallelQuery<TSource> : ParallelQuery<T>

Type Parameters

TSource

Inheritance Hierarchy

System..::.Object
System.Linq..::.ParallelQuery
System.Linq..::.ParallelQuery <(Of <(T>)>)
System.Linq..::.OrderedParallelQuery<(Of <(TSource>)>)

See Also

System.Linq Namespace


OrderedParallelQuery(TSource) Methods

[image] [image]

.NET Framework Class Library
OrderedParallelQuery<(Of <(TSource>)>) Methods
OrderedParallelQuery<(Of <(TSource>)>) Class See Also Send Feedback

The OrderedParallelQuery<(Of <(TSource>)>) type exposes the following members.

Methods

Name | Description
Equals | (Inherited from Object.)
Finalize | (Inherited from Object.)
GetEnumerator | Returns an enumerator that iterates through the sequence. (Overrides ParallelQuery<(Of <(TSource>)>)..::.GetEnumerator()()().)
GetHashCode | (Inherited from Object.)
GetType | (Inherited from Object.)
MemberwiseClone | (Inherited from Object.)
ToString | (Inherited from Object.)

Explicit Interface Implementations

Name | Description
IEnumerable..::.GetEnumerator | Returns an enumerator that iterates through the sequence. (Inherited from ParallelQuery.)

See Also

OrderedParallelQuery<(Of <(TSource>)>) Class
System.Linq Namespace


GetEnumerator Method

[image]

.NET Framework Class Library
OrderedParallelQuery<(Of <(TSource>)>)..::.GetEnumerator Method
OrderedParallelQuery<(Of <(TSource>)>) Class See Also Send Feedback

Returns an enumerator that iterates through the sequence.

Namespace: System.Linq
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Overrides Function GetEnumerator As IEnumerator(Of TSource)
C#
public override IEnumerator<TSource> GetEnumerator()

Return Value

An enumerator that iterates through the sequence.

See Also

OrderedParallelQuery<(Of <(TSource>)>) Class
System.Linq Namespace


ParallelEnumerable Class

[image]

.NET Framework Class Library
ParallelEnumerable Class
See Also Send Feedback

Provides a set of methods for querying objects that implement ParallelQuery{TSource}. This is the parallel equivalent of Enumerable.

Namespace: System.Linq
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public NotInheritable Class ParallelEnumerable
C#
public static class ParallelEnumerable

Inheritance Hierarchy

System..::.Object
System.Linq..::.ParallelEnumerable

See Also

System.Linq Namespace


ParallelEnumerable Methods

[image] [image]

.NET Framework Class Library
ParallelEnumerable Methods
ParallelEnumerable Class See Also Send Feedback

The ParallelEnumerable type exposes the following members.

Methods

Name | Description
Aggregate | Overloaded.
All<(Of <(TSource>)>) | Determines in parallel whether all elements of a sequence satisfy a condition.
Any | Overloaded.
AsEnumerable<(Of <(TSource>)>) | Converts a ParallelQuery<(Of <(TSource>)>) into an IEnumerable<(Of <(T>)>) to force sequential evaluation of the query.
AsOrdered | Overloaded.
AsParallel | Overloaded.
AsSequential<(Of <(TSource>)>) | Converts a ParallelQuery<(Of <(TSource>)>) into an IEnumerable<(Of <(T>)>) to force sequential evaluation of the query.
AsUnordered<(Of <(TSource>)>) | Allows an intermediate query to be treated as if no ordering is implied among the elements.
Average | Overloaded.
Cast<(Of <(TResult>)>) | Converts the elements of a ParallelQuery to the specified type.
Concat | Overloaded.
Contains | Overloaded.
Count | Overloaded.
DefaultIfEmpty | Overloaded.
Distinct | Overloaded.
ElementAt<(Of <(TSource>)>) | Returns the element at a specified index in a parallel sequence.
ElementAtOrDefault<(Of <(TSource>)>) | Returns the element at a specified index in a parallel sequence or a default value if the index is out of range.
Empty<(Of <(TResult>)>) | Returns an empty ParallelQuery{TResult} that has the specified type argument.
Except | Overloaded.
First | Overloaded.
FirstOrDefault | Overloaded.
ForAll<(Of <(TSource>)>) | Invokes in parallel the specified action for each element in the source.
GroupBy | Overloaded.
GroupJoin | Overloaded.
Intersect | Overloaded.
Join | Overloaded.
Last | Overloaded.
LastOrDefault | Overloaded.
LongCount | Overloaded.
Max | Overloaded.
Min | Overloaded.
OfType<(Of <(TResult>)>) | Filters the elements of a ParallelQuery based on a specified type.
OrderBy | Overloaded.
OrderByDescending | Overloaded.
Range | Generates a parallel sequence of integral numbers within a specified range.
Repeat<(Of <(TResult>)>) | Generates a parallel sequence that contains one repeated value.
Reverse<(Of <(TSource>)>) | Inverts the order of the elements in a parallel sequence.
Select | Overloaded.
SelectMany | Overloaded.
SequenceEqual | Overloaded.
Single | Overloaded.
SingleOrDefault | Overloaded.
Skip<(Of <(TSource>)>) | Bypasses a specified number of elements in a parallel sequence and then returns the remaining elements.
SkipWhile | Overloaded.
Sum | Overloaded.
Take<(Of <(TSource>)>) | Returns a specified number of contiguous elements from the start of a parallel sequence.
TakeWhile | Overloaded.
ThenBy | Overloaded.
ThenByDescending | Overloaded.
ToArray<(Of <(TSource>)>) | Creates an array from a ParallelQuery{T}.
ToDictionary | Overloaded.
ToList<(Of <(TSource>)>) | Creates a List{T} from an ParallelQuery{T}.
ToLookup | Overloaded.
Union | Overloaded.
Where | Overloaded.
WithCancellation<(Of <(TSource>)>) | Sets the CancellationToken to associate with the query.
WithDegreeOfParallelism<(Of <(TSource>)>) | Sets the degree of parallelism to use in a query. Degree of parallelism is the maximum number of concurrently executing tasks that will be used to process the query.
WithExecutionMode<(Of <(TSource>)>) | Sets the execution mode of the query.
WithMergeOptions<(Of <(TSource>)>) | Sets the merge options for this query, which specify how the query will buffer output.
Zip | Overloaded.

See Also

ParallelEnumerable Class
System.Linq Namespace


Aggregate Method

[image] [image]

.NET Framework Class Library
ParallelEnumerable..::.Aggregate Method
ParallelEnumerable Class See Also Send Feedback

Overload List

Name | Description
Aggregate<(Of <(TSource>)>)(ParallelQuery<(Of <(TSource>)>), Func<(Of <(TSource, TSource, TSource>)>)) | Applies in parallel an accumulator function over a sequence.
Aggregate<(Of <(TSource, TAccumulate>)>)(ParallelQuery<(Of <(TSource>)>), TAccumulate, Func<(Of <(TAccumulate, TSource, TAccumulate>)>)) | Applies in parallel an accumulator function over a sequence. The specified seed value is used as the initial accumulator value.
Aggregate<(Of <(TSource, TAccumulate, TResult>)>)(ParallelQuery<(Of <(TSource>)>), TAccumulate, Func<(Of <(TAccumulate, TSource, TAccumulate>)>), Func<(Of <(TAccumulate, TResult>)>)) | Applies in parallel 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.
Aggregate<(Of <(TSource, TAccumulate, TResult>)>)(ParallelQuery<(Of <(TSource>)>), Func<(Of <(TAccumulate>)>), Func<(Of <(TAccumulate, TSource, TAccumulate>)>), Func<(Of <(TAccumulate, TAccumulate, TAccumulate>)>), Func<(Of <(TAccumulate, TResult>)>)) | Applies in parallel an accumulator function over a sequence. This overload is not available in the sequential implementation.
Aggregate<(Of <(TSource, TAccumulate, TResult>)>)(ParallelQuery<(Of <(TSource>)>), TAccumulate, Func<(Of <(TAccumulate, TSource, TAccumulate>)>), Func<(Of <(TAccumulate, TAccumulate, TAccumulate>)>), Func<(Of <(TAccumulate, TResult>)>)) | Applies in parallel an accumulator function over a sequence. This overload is not available in the sequential implementation.

See Also

ParallelEnumerable Class
System.Linq Namespace


Aggregate(TSource) Method (ParallelQuery(TSource), Func(TSource, TSource, TSource))

[image]

.NET Framework Class Library
ParallelEnumerable..::.Aggregate<(Of <(TSource>)>) Method (ParallelQuery<(Of <(TSource>)>), Func<(Of <(TSource, TSource, TSource>)>))
ParallelEnumerable Class See Also Send Feedback

Applies in parallel an accumulator function over a sequence.

Namespace: System.Linq
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function Aggregate(Of TSource) ( _
    source As ParallelQuery(Of TSource), _
    func As Func(Of TSource, TSource, TSource) _
) As TSource
C#
public static TSource Aggregate<TSource>(
    ParallelQuery<TSource> source,
    Func<TSource, TSource, TSource> func
)

Parameters

source
Type: System.Linq..::.ParallelQuery <(Of <(TSource>)>)
A sequence to aggregate over.
func
Type: System..::.Func<(Of <(TSource, TSource, TSource>)>)
An accumulator function to be invoked on each element.

Type Parameters

TSource
The type of the elements of source.

Return Value

The final accumulator value.

Exceptions

Exception | Condition
System..::.ArgumentNullException | source or func is a null reference (Nothing in Visual Basic).
System..::.InvalidOperationException | source contains no elements.
System..::.AggregateException | One or more exceptions occurred during the evaluation of the query.
System..::.OperationCanceledException | The query was canceled.

See Also

ParallelEnumerable Class
Aggregate Overload
System.Linq Namespace


Aggregate(TSource, TAccumulate) Method (ParallelQuery(TSource), TAccumulate, Func(TAccumulate, TSource, TAccumulate))

[image]

.NET Framework Class Library
ParallelEnumerable..::.Aggregate<(Of <(TSource, TAccumulate>)>) Method (ParallelQuery<(Of <(TSource>)>), TAccumulate, Func<(Of <(TAccumulate, TSource, TAccumulate>)>))
ParallelEnumerable Class See Also Send Feedback

Applies in parallel an accumulator function over a sequence. The specified seed value is used as the initial accumulator value.

Namespace: System.Linq
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function Aggregate(Of TSource, TAccumulate) ( _
    source As ParallelQuery(Of TSource), _
    seed As TAccumulate, _
    func As Func(Of TAccumulate, TSource, TAccumulate) _
) As TAccumulate
C#
public static TAccumulate Aggregate<TSource, TAccumulate>(
    ParallelQuery<TSource> source,
    TAccumulate seed,
    Func<TAccumulate, TSource, TAccumulate> func
)

Parameters

source
Type: System.Linq..::.ParallelQuery <(Of <(TSource>)>)
A sequence to aggregate over.
seed
Type: TAccumulate
The initial accumulator value.
func
Type: System..::.Func<(Of <(TAccumulate, TSource, TAccumulate>)>)
An accumulator function to be invoked on each element.

Type Parameters

TSource
The type of the elements of source.
TAccumulate
The type of the accumulator value.

Return Value

The final accumulator value.

Exceptions

Exception | Condition
System..::.ArgumentNullException | source or func is a null reference (Nothing in Visual Basic).
System..::.AggregateException | One or more exceptions occurred during the evaluation of the query.
System..::.OperationCanceledException | The query was canceled.

See Also

ParallelEnumerable Class
Aggregate Overload
System.Linq Namespace


Aggregate(TSource, TAccumulate, TResult) Method (ParallelQuery(TSource), TAccumulate, Func(TAccumulate, TSource, TAccumulate), Func(TAccumulate, TResult))

[image]

.NET Framework Class Library
ParallelEnumerable..::.Aggregate<(Of <(TSource, TAccumulate, TResult>)>) Method (ParallelQuery<(Of <(TSource>)>), TAccumulate, Func<(Of <(TAccumulate, TSource, TAccumulate>)>), Func<(Of <(TAccumulate, TResult>)>))
ParallelEnumerable Class See Also Send Feedback

Applies in parallel 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.

Namespace: System.Linq
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function Aggregate(Of TSource, TAccumulate, TResult) ( _
    source As ParallelQuery(Of TSource), _
    seed As TAccumulate, _
    func As Func(Of TAccumulate, TSource, TAccumulate), _
    resultSelector As Func(Of TAccumulate, TResult) _
) As TResult
C#
public static TResult Aggregate<TSource, TAccumulate, TResult>(
    ParallelQuery<TSource> source,
    TAccumulate seed,
    Func<TAccumulate, TSource, TAccumulate> func,
    Func<TAccumulate, TResult> resultSelector
)

Parameters

source
Type: System.Linq..::.ParallelQuery <(Of <(TSource>)>)
A sequence to aggregate over.
seed
Type: TAccumulate
The initial accumulator value.
func
Type: System..::.Func<(Of <(TAccumulate, TSource, TAccumulate>)>)
An accumulator function to be invoked on each element.
resultSelector
Type: System..::.Func<(Of <(TAccumulate, TResult>)>)
A function to transform the final accumulator value into the result value.

Type Parameters

TSource
The type of the elements of source.
TAccumulate
The type of the accumulator value.
TResult
The type of the resulting value.

Return Value

The transformed final accumulator value.

Exceptions

Exception | Condition
System..::.ArgumentNullException | source or func or resultSelector is a null reference (Nothing in Visual Basic).
System..::.AggregateException | One or more exceptions occurred during the evaluation of the query.
System..::.OperationCanceledException | The query was canceled.

See Also

ParallelEnumerable Class
Aggregate Overload
System.Linq Namespace


Aggregate(TSource, TAccumulate, TResult) Method (ParallelQuery(TSource), Func(TAccumulate), Func(TAccumulate, TSource, TAccumulate), Func(TAccumulate, TAccumulate, TAccumulate), Func(TAccumulate, TResult))

[image]

.NET Framework Class Library
ParallelEnumerable..::.Aggregate<(Of <(TSource, TAccumulate, TResult>)>) Method (ParallelQuery<(Of <(TSource>)>), Func<(Of <(TAccumulate>)>), Func<(Of <(TAccumulate, TSource, TAccumulate>)>), Func<(Of <(TAccumulate, TAccumulate, TAccumulate>)>), Func<(Of <(TAccumulate, TResult>)>))
ParallelEnumerable Class See Also Send Feedback

Applies in parallel an accumulator function over a sequence. This overload is not available in the sequential implementation.

Namespace: System.Linq
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function Aggregate(Of TSource, TAccumulate, TResult) ( _
    source As ParallelQuery(Of TSource), _
    seedFactory As Func(Of TAccumulate), _
    updateAccumulatorFunc As Func(Of TAccumulate, TSource, TAccumulate), _
    combineAccumulatorsFunc As Func(Of TAccumulate, TAccumulate, TAccumulate), _
    resultSelector As Func(Of TAccumulate, TResult) _
) As TResult
C#
public static TResult Aggregate<TSource, TAccumulate, TResult>(
    ParallelQuery<TSource> source,
    Func<TAccumulate> seedFactory,
    Func<TAccumulate, TSource, TAccumulate> updateAccumulatorFunc,
    Func<TAccumulate, TAccumulate, TAccumulate> combineAccumulatorsFunc,
    Func<TAccumulate, TResult> resultSelector
)

Parameters

source
Type: System.Linq..::.ParallelQuery <(Of <(TSource>)>)
A sequence to aggregate over.
seedFactory
Type: System..::.Func<(Of <(TAccumulate>)>)
A function that returns the initial accumulator value.
updateAccumulatorFunc
Type: System..::.Func<(Of <(TAccumulate, TSource, TAccumulate>)>)
An accumulator function to be invoked on each element in a partition.
combineAccumulatorsFunc
Type: System..::.Func<(Of <(TAccumulate, TAccumulate, TAccumulate>)>)
An accumulator function to be invoked on the yielded element from each partition.
resultSelector
Type: System..::.Func<(Of <(TAccumulate, TResult>)>)
A function to transform the final accumulator value into the result value.

Type Parameters

TSource
The type of the elements of source.
TAccumulate
The type of the accumulator value.
TResult
The type of the resulting value.

Return Value

The transformed final accumulator value.

Remarks

This overload is specific to parallelized queries. A parallelized query may partition the data source sequence into several sub-sequences (partitions). The updateAccumulatorFunc is invoked on each element within partitions. Each partition then yields a single accumulated result. The combineAccumulatorsFunc is then invoked on the results of each partition to yield a single element. This element is then transformed by the resultSelector function.

Exceptions

Exception | Condition
System..::.ArgumentNullException | source or seedFactory or updateAccumulatorFunc or combineAccumulatorsFunc or resultSelector is a null reference (Nothing in Visual Basic).
System..::.AggregateException | One or more exceptions occurred during the evaluation of the query.
System..::.OperationCanceledException | The query was canceled.

See Also

ParallelEnumerable Class
Aggregate Overload
System.Linq Namespace


Aggregate(TSource, TAccumulate, TResult) Method (ParallelQuery(TSource), TAccumulate, Func(TAccumulate, TSource, TAccumulate), Func(TAccumulate, TAccumulate, TAccumulate), Func(TAccumulate, TResult))

[image]

.NET Framework Class Library
ParallelEnumerable..::.Aggregate<(Of <(TSource, TAccumulate, TResult>)>) Method (ParallelQuery<(Of <(TSource>)>), TAccumulate, Func<(Of <(TAccumulate, TSource, TAccumulate>)>), Func<(Of <(TAccumulate, TAccumulate, TAccumulate>)>), Func<(Of <(TAccumulate, TResult>)>))
ParallelEnumerable Class See Also Send Feedback

Applies in parallel an accumulator function over a sequence. This overload is not available in the sequential implementation.

Namespace: System.Linq
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function Aggregate(Of TSource, TAccumulate, TResult) ( _
    source As ParallelQuery(Of TSource), _
    seed As TAccumulate, _
    updateAccumulatorFunc As Func(Of TAccumulate, TSource, TAccumulate), _
    combineAccumulatorsFunc As Func(Of TAccumulate, TAccumulate, TAccumulate), _
    resultSelector As Func(Of TAccumulate, TResult) _
) As TResult
C#
public static TResult Aggregate<TSource, TAccumulate, TResult>(
    ParallelQuery<TSource> source,
    TAccumulate seed,
    Func<TAccumulate, TSource, TAccumulate> updateAccumulatorFunc,
    Func<TAccumulate, TAccumulate, TAccumulate> combineAccumulatorsFunc,
    Func<TAccumulate, TResult> resultSelector
)

Parameters

source
Type: System.Linq..::.ParallelQuery <(Of <(TSource>)>)
A sequence to aggregate over.
seed
Type: TAccumulate
The initial accumulator value.
updateAccumulatorFunc
Type: System..::.Func<(Of <(TAccumulate, TSource, TAccumulate>)>)
An accumulator function to be invoked on each element in a partition.
combineAccumulatorsFunc
Type: System..::.Func<(Of <(TAccumulate, TAccumulate, TAccumulate>)>)
An accumulator function to be invoked on the yielded element from each partition.
resultSelector
Type: System..::.Func<(Of <(TAccumulate, TResult>)>)
A function to transform the final accumulator value into the result value.

Type Parameters

TSource
The type of the elements of source.
TAccumulate
The type of the accumulator value.
TResult
The type of the resulting value.

Return Value

The transformed final accumulator value.

Remarks

This overload is specific to processing a parallelized query. A parallelized query may partition the data source sequence into several sub-sequences (partitions). The updateAccumulatorFunc is invoked on each element within partitions. Each partition then yields a single accumulated result. The combineAccumulatorsFunc is then invoked on the results of each partition to yield a single element. This element is then transformed by the resultSelector function.

Exceptions

Exception | Condition
System..::.ArgumentNullException | source or updateAccumulatorFunc or combineAccumulatorsFunc or resultSelector is a null reference (Nothing in Visual Basic).
System..::.AggregateException | One or more exceptions occurred during the evaluation of the query.
System..::.OperationCanceledException | The query was canceled.

See Also

ParallelEnumerable Class
Aggregate Overload
System.Linq Namespace


All(TSource) Method

[image]

.NET Framework Class Library
ParallelEnumerable..::.All<(Of <(TSource>)>) Method
ParallelEnumerable Class See Also Send Feedback

Determines in parallel whether all elements of a sequence satisfy a condition.

Namespace: System.Linq
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function All(Of TSource) ( _
    source As ParallelQuery(Of TSource), _
    predicate As Func(Of TSource, Boolean) _
) As Boolean
C#
public static bool All<TSource>(
    ParallelQuery<TSource> source,
    Func<TSource, bool> predicate
)

Parameters

source
Type: System.Linq..::.ParallelQuery <(Of <(TSource>)>)
A sequence whose elements to apply the predicate to.
predicate
Type: System..::.Func<(Of <(TSource, Boolean>)>)
A function to test each element for a condition.

Type Parameters

TSource
The type of elements of source.

Return Value

true if all elements in the source sequence pass the test in the specified predicate; otherwise, false.

Exceptions

Exception | Condition
System..::.ArgumentNullException | source or predicate is a null reference (Nothing in Visual Basic).
System..::.AggregateException | One or more exceptions occurred during the evaluation of the query.
System..::.OperationCanceledException | The query was canceled.

See Also

ParallelEnumerable Class
System.Linq Namespace


Any Method

[image] [image]

.NET Framework Class Library
ParallelEnumerable..::.Any Method
ParallelEnumerable Class See Also Send Feedback

Overload List

Name | Description
Any<(Of <(TSource>)>)(ParallelQuery<(Of <(TSource>)>)) | Determines whether a parallel sequence contains any elements.
Any<(Of <(TSource>)>)(ParallelQuery<(Of <(TSource>)>), Func<(Of <(TSource, Boolean>)>)) | Determines in parallel whether any element of a sequence satisfies a condition.

See Also

ParallelEnumerable Class
System.Linq Namespace


Any(TSource) Method (ParallelQuery(TSource))

[image]

.NET Framework Class Library
ParallelEnumerable..::.Any<(Of <(TSource>)>) Method (ParallelQuery<(Of <(TSource>)>))
ParallelEnumerable Class See Also Send Feedback

Determines whether a parallel sequence contains any elements.

Namespace: System.Linq
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function Any(Of TSource) ( _
    source As ParallelQuery(Of TSource) _
) As Boolean
C#
public static bool Any<TSource>(
    ParallelQuery<TSource> source
)

Parameters

source
Type: System.Linq..::.ParallelQuery <(Of <(TSource>)>)
The IEnumerable to check for emptiness.

Type Parameters

TSource
The type of elements of source.

Return Value

true if the source sequence contains any elements; otherwise, false.

Exceptions

Exception | Condition
System..::.ArgumentNullException | source is a null reference (Nothing in Visual Basic).
System..::.AggregateException | One or more exceptions occurred during the evaluation of the query.
System..::.OperationCanceledException | The query was canceled.

See Also

ParallelEnumerable Class
Any Overload
System.Linq Namespace


Any(TSource) Method (ParallelQuery(TSource), Func(TSource, Boolean))

[image]

.NET Framework Class Library
ParallelEnumerable..::.Any<(Of <(TSource>)>) Method (ParallelQuery<(Of <(TSource>)>), Func<(Of <(TSource, Boolean>)>))
ParallelEnumerable Class See Also Send Feedback

Determines in parallel whether any element of a sequence satisfies a condition.

Namespace: System.Linq
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function Any(Of TSource) ( _
    source As ParallelQuery(Of TSource), _
    predicate As Func(Of TSource, Boolean) _
) As Boolean
C#
public static bool Any<TSource>(
    ParallelQuery<TSource> source,
    Func<TSource, bool> predicate
)

Parameters

source
Type: System.Linq..::.ParallelQuery <(Of <(TSource>)>)
An IEnumerable whose elements to apply the predicate to.
predicate
Type: System..::.Func<(Of <(TSource, Boolean>)>)
A function to test each element for a condition.

Type Parameters

TSource
The type of elements of source.

Return Value

true if any elements in the source sequence pass the test in the specified predicate; otherwise, false.

Exceptions

Exception | Condition
System..::.ArgumentNullException | source or predicate is a null reference (Nothing in Visual Basic).
System..::.AggregateException | One or more exceptions occurred during the evaluation of the query.
System..::.OperationCanceledException | The query was canceled.

See Also

ParallelEnumerable Class
Any Overload
System.Linq Namespace


AsEnumerable(TSource) Method

[image]

.NET Framework Class Library
ParallelEnumerable..::.AsEnumerable<(Of <(TSource>)>) Method
ParallelEnumerable Class See Also Send Feedback

Converts a ParallelQuery<(Of <(TSource>)>) into an IEnumerable<(Of <(T>)>) to force sequential evaluation of the query.

Namespace: System.Linq
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function AsEnumerable(Of TSource) ( _
    source As ParallelQuery(Of TSource) _
) As IEnumerable(Of TSource)
C#
public static IEnumerable<TSource> AsEnumerable<TSource>(
    ParallelQuery<TSource> source
)

Parameters

source
Type: System.Linq..::.ParallelQuery <(Of <(TSource>)>)
The sequence to type as IEnumerable<(Of <(T>)>).

Type Parameters

TSource
The type of the elements of source.

Return Value

The input sequence types as IEnumerable<(Of <(T>)>).

Exceptions

Exception | Condition
System..::.ArgumentNullException | source is a null reference (Nothing in Visual Basic).

See Also

ParallelEnumerable Class
System.Linq Namespace


AsOrdered Method

[image] [image]

.NET Framework Class Library
ParallelEnumerable..::.AsOrdered Method
ParallelEnumerable Class See Also Send Feedback

Overload List

Name | Description
AsOrdered(ParallelQuery) | Enables treatment of a data source as if it was ordered, overriding the default of unordered. AsOrdered may only be invoked on sequences returned by AsParallel, ParallelEnumerable.Range, and ParallelEnumerable.Repeat.
AsOrdered<(Of <(TSource>)>)(ParallelQuery<(Of <(TSource>)>)) | Enables treatment of a data source as if it was ordered, overriding the default of unordered. AsOrdered may only be invoked on sequences returned by AsParallel, ParallelEnumerable.Range, and ParallelEnumerable.Repeat.

See Also

ParallelEnumerable Class
System.Linq Namespace


AsOrdered Method (ParallelQuery)

[image]

.NET Framework Class Library
ParallelEnumerable..::.AsOrdered Method (ParallelQuery)
ParallelEnumerable Class See Also Send Feedback

Enables treatment of a data source as if it was ordered, overriding the default of unordered. AsOrdered may only be invoked on sequences returned by AsParallel, ParallelEnumerable.Range, and ParallelEnumerable.Repeat.

Namespace: System.Linq
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function AsOrdered ( _
    source As ParallelQuery _
) As ParallelQuery
C#
public static ParallelQuery AsOrdered(
    ParallelQuery source
)

Parameters

source
Type: System.Linq..::.ParallelQuery
The input sequence.

Return Value

The source sequence which will maintain ordering in the query.

Remarks

A natural tension exists between performance and preserving order in parallel processing. By default, a parallelized query behaves as if the ordering of the results is arbitrary unless AsOrdered is applied or there is an explicit OrderBy operator in the query.

Exceptions

Exception | Condition
System..::.InvalidOperationException | Thrown if the source is not one of AsParallel, ParallelEnumerable.Range, or ParallelEnumerable.Repeat.
System..::.ArgumentNullException | source is a null reference (Nothing in Visual Basic).

See Also

ParallelEnumerable Class
AsOrdered Overload
System.Linq Namespace


AsOrdered(TSource) Method (ParallelQuery(TSource))

[image]

.NET Framework Class Library
ParallelEnumerable..::.AsOrdered<(Of <(TSource>)>) Method (ParallelQuery<(Of <(TSource>)>))
ParallelEnumerable Class See Also Send Feedback

Enables treatment of a data source as if it was ordered, overriding the default of unordered. AsOrdered may only be invoked on sequences returned by AsParallel, ParallelEnumerable.Range, and ParallelEnumerable.Repeat.

Namespace: System.Linq
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function AsOrdered(Of TSource) ( _
    source As ParallelQuery(Of TSource) _
) As ParallelQuery(Of TSource)
C#
public static ParallelQuery<TSource> AsOrdered<TSource>(
    ParallelQuery<TSource> source
)

Parameters

source
Type: System.Linq..::.ParallelQuery <(Of <(TSource>)>)
The input sequence.

Type Parameters

TSource
The type of elements of source.

Return Value

The source sequence which will maintain ordering in the query.

Remarks

A natural tension exists between performance and preserving order in parallel processing. By default, a parallelized query behaves as if the ordering of the results is arbitrary unless AsOrdered is applied or there is an explicit OrderBy operator in the query.

Exceptions

Exception | Condition
System..::.InvalidOperationException | Thrown if source is not one of AsParallel, ParallelEnumerable.Range, or ParallelEnumerable.Repeat.
System..::.ArgumentNullException | source is a null reference (Nothing in Visual Basic).

See Also

ParallelEnumerable Class
AsOrdered Overload
System.Linq Namespace


AsParallel Method

[image] [image]

.NET Framework Class Library
ParallelEnumerable..::.AsParallel Method
ParallelEnumerable Class See Also Send Feedback

Overload List

Name | Description
AsParallel<(Of <(TSource>)>)(Partitioner<(Of <(TSource>)>)) | Enables parallelization of a query, as sourced by a partitioner responsible for splitting the input sequence into partitions.
AsParallel<(Of <(TSource>)>)(IEnumerable<(Of <(TSource>)>)) | Enables parallelization of a query.
AsParallel(IEnumerable) | Enables parallelization of a query.

See Also

ParallelEnumerable Class
System.Linq Namespace


AsParallel(TSource) Method (Partitioner(TSource))

[image]

.NET Framework Class Library
ParallelEnumerable..::.AsParallel<(Of <(TSource>)>) Method (Partitioner<(Of <(TSource>)>))
ParallelEnumerable Class See Also Send Feedback

Enables parallelization of a query, as sourced by a partitioner responsible for splitting the input sequence into partitions.

Namespace: System.Linq
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function AsParallel(Of TSource) ( _
    source As Partitioner(Of TSource) _
) As ParallelQuery(Of TSource)
C#
public static ParallelQuery<TSource> AsParallel<TSource>(
    Partitioner<TSource> source
)

Parameters

source
Type: System.Collections.Concurrent..::.Partitioner <(Of <(TSource>)>)
A partitioner over the input sequence.

Type Parameters

TSource
The type of elements of source.

Return Value

The source as a ParallelQuery to bind to ParallelEnumerable extension methods.

Remarks

The source partitioner's GetOrderedPartitions method is used when ordering is enabled, whereas the partitioner's GetPartitions is used if ordering is not enabled (the default). The source partitioner's GetDynamicPartitions and GetDynamicOrderedPartitions are not used.

Exceptions

Exception | Condition
System..::.ArgumentNullException | source is a null reference (Nothing in Visual Basic).

See Also

ParallelEnumerable Class
AsParallel Overload
System.Linq Namespace


AsParallel(TSource) Method (IEnumerable(TSource))

[image]

.NET Framework Class Library
ParallelEnumerable..::.AsParallel<(Of <(TSource>)>) Method (IEnumerable<(Of <(TSource>)>))
ParallelEnumerable Class See Also Send Feedback

Enables parallelization of a query.

Namespace: System.Linq
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function AsParallel(Of TSource) ( _
    source As IEnumerable(Of TSource) _
) As ParallelQuery(Of TSource)
C#
public static ParallelQuery<TSource> AsParallel<TSource>(
    IEnumerable<TSource> source
)

Parameters

source
Type: System.Collections.Generic..::.IEnumerable<(Of <(TSource>)>)
An IEnumerable<(Of <(T>)>) to convert to a ParallelQuery<(Of <(TSource>)>).

Type Parameters

TSource
The type of elements of source.

Return Value

The source as a ParallelQuery<(Of <(TSource>)>) to bind to ParallelEnumerable extension methods.

Exceptions

Exception | Condition
System..::.ArgumentNullException | source is a null reference (Nothing in Visual Basic).

See Also

ParallelEnumerable Class
AsParallel Overload
System.Linq Namespace


AsParallel Method (IEnumerable)

[image]

.NET Framework Class Library
ParallelEnumerable..::.AsParallel Method (IEnumerable)
ParallelEnumerable Class See Also Send Feedback

Enables parallelization of a query.

Namespace: System.Linq
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function AsParallel ( _
    source As IEnumerable _
) As ParallelQuery
C#
public static ParallelQuery AsParallel(
    IEnumerable source
)

Parameters

source
Type: System.Collections..::.IEnumerable
An IEnumerable<(Of <(T>)>) to convert to a ParallelQuery<(Of <(TSource>)>).

Return Value

The source as a ParallelQuery to bind to ParallelEnumerable extension methods.

Exceptions

Exception | Condition
System..::.ArgumentNullException | source is a null reference (Nothing in Visual Basic).

See Also

ParallelEnumerable Class
AsParallel Overload
System.Linq Namespace


AsSequential(TSource) Method

[image]

.NET Framework Class Library
ParallelEnumerable..::.AsSequential<(Of <(TSource>)>) Method
ParallelEnumerable Class See Also Send Feedback

Converts a ParallelQuery<(Of <(TSource>)>) into an IEnumerable<(Of <(T>)>) to force sequential evaluation of the query.

Namespace: System.Linq
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function AsSequential(Of TSource) ( _
    source As ParallelQuery(Of TSource) _
) As IEnumerable(Of TSource)
C#
public static IEnumerable<TSource> AsSequential<TSource>(
    ParallelQuery<TSource> source
)

Parameters

source
Type: System.Linq..::.ParallelQuery <(Of <(TSource>)>)
A ParallelQuery<(Of <(TSource>)>) to convert to an IEnumerable<(Of <(T>)>).

Type Parameters

TSource
The type of elements of source.

Return Value

The source as an IEnumerable<(Of <(T>)>) to bind to sequential extension methods.

Exceptions

Exception | Condition
System..::.ArgumentNullException | source is a null reference (Nothing in Visual Basic).

See Also

ParallelEnumerable Class
System.Linq Namespace


AsUnordered(TSource) Method

[image]

.NET Framework Class Library
ParallelEnumerable..::.AsUnordered<(Of <(TSource>)>) Method
ParallelEnumerable Class See Also Send Feedback

Allows an intermediate query to be treated as if no ordering is implied among the elements.

Namespace: System.Linq
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function AsUnordered(Of TSource) ( _
    source As ParallelQuery(Of TSource) _
) As ParallelQuery(Of TSource)
C#
public static ParallelQuery<TSource> AsUnordered<TSource>(
    ParallelQuery<TSource> source
)

Parameters

source
Type: System.Linq..::.ParallelQuery <(Of <(TSource>)>)
The input sequence.

Type Parameters

TSource
The type of elements of source.

Return Value

The source sequence with arbitrary order.

Remarks

AsUnordered may provide performance benefits when ordering is not required in a portion of a query.

Exceptions

Exception | Condition
System..::.ArgumentNullException | source is a null reference (Nothing in Visual Basic).

See Also

ParallelEnumerable Class
System.Linq Namespace


Average Method

[image] [image]

.NET Framework Class Library
ParallelEnumerable..::.Average Method
ParallelEnumerable Class See Also Send Feedback

Overload List

Name | Description
Average(ParallelQuery<(Of <(Decimal>)>)) | Computes in parallel the average of a sequence of values.
Average(ParallelQuery<(Of <(Double>)>)) | Computes in parallel the average of a sequence of values.
Average(ParallelQuery<(Of <(Int32>)>)) | Computes in parallel the average of a sequence of values.
Average(ParallelQuery<(Of <(Int64>)>)) | Computes in parallel the average of a sequence of values.
Average(ParallelQuery<(Of <(Nullable<(Of <(Decimal>)>)>)>)) | Computes in parallel the average of a sequence of values.
Average(ParallelQuery<(Of <(Nullable<(Of <(Double>)>)>)>)) | Computes in parallel the average of a sequence of values.
Average(ParallelQuery<(Of <(Nullable<(Of <(Int32>)>)>)>)) | Computes in parallel the average of a sequence of values.
Average(ParallelQuery<(Of <(Nullable<(Of <(Int64>)>)>)>)) | Computes in parallel the average of a sequence of values.
Average(ParallelQuery<(Of <(Nullable<(Of <(Single>)>)>)>)) | Computes in parallel the average of a sequence of values.
Average(ParallelQuery<(Of <(Single>)>)) | Computes in parallel the average of a sequence of values.
Average<(Of <(TSource>)>)(ParallelQuery<(Of <(TSource>)>), Func<(Of <(TSource, Decimal>)>)) | Computes in parallel the average of a sequence of values that are obtained by invoking a transform function on each element of the input sequence.
Average<(Of <(TSource>)>)(ParallelQuery<(Of <(TSource>)>), Func<(Of <(TSource, Double>)>)) | Computes in parallel the average of a sequence of values that are obtained by invoking a transform function on each element of the input sequence.
Average<(Of <(TSource>)>)(ParallelQuery<(Of <(TSource>)>), Func<(Of <(TSource, Int32>)>)) | Computes in parallel the average of a sequence of values that are obtained by invoking a transform function on each element of the input sequence.
Average<(Of <(TSource>)>)(ParallelQuery<(Of <(TSource>)>), Func<(Of <(TSource, Int64>)>)) | Computes in parallel the average of a sequence of values that are obtained by invoking a transform function on each element of the input sequence.
Average<(Of <(TSource>)>)(ParallelQuery<(Of <(TSource>)>), Func<(Of <(TSource, Nullable<(Of <(Decimal>)>)>)>)) | Computes in parallel the average of a sequence of values that are obtained by invoking a transform function on each element of the input sequence.
Average<(Of <(TSource>)>)(ParallelQuery<(Of <(TSource>)>), Func<(Of <(TSource, Nullable<(Of <(Double>)>)>)>)) | Computes in parallel the average of a sequence of values that are obtained by invoking a transform function on each element of the input sequence.
Average<(Of <(TSource>)>)(ParallelQuery<(Of <(TSource>)>), Func<(Of <(TSource, Nullable<(Of <(Int32>)>)>)>)) | Computes in parallel the average of a sequence of values that are obtained by invoking a transform function on each element of the input sequence.
Average<(Of <(TSource>)>)(ParallelQuery<(Of <(TSource>)>), Func<(Of <(TSource, Nullable<(Of <(Int64>)>)>)>)) | Computes in parallel the average of a sequence of values that are obtained by invoking a transform function on each element of the input sequence.
Average<(Of <(TSource>)>)(ParallelQuery<(Of <(TSource>)>), Func<(Of <(TSource, Nullable<(Of <(Single>)>)>)>)) | Computes in parallel the average of a sequence of values that are obtained by invoking a transform function on each element of the input sequence.
Average<(Of <(TSource>)>)(ParallelQuery<(Of <(TSource>)>), Func<(Of <(TSource, Single>)>)) | Computes in parallel the average of a sequence of values that are obtained by invoking a transform function on each element of the input sequence.

See Also

ParallelEnumerable Class
System.Linq Namespace


Average Method (ParallelQuery(Decimal))

[image]

.NET Framework Class Library
ParallelEnumerable..::.Average Method (ParallelQuery<(Of <(Decimal>)>))
ParallelEnumerable Class See Also Send Feedback

Computes in parallel the average of a sequence of values.

Namespace: System.Linq
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function Average ( _
    source As ParallelQuery(Of Decimal) _
) As Decimal
C#
public static decimal Average(
    ParallelQuery<decimal> source
)

Parameters

source
Type: System.Linq..::.ParallelQuery <(Of <(Decimal>)>)
A sequence of values that are used to calculate an average.

Return Value

The average of the sequence of values.

Exceptions

Exception | Condition
System..::.ArgumentNullException | source is a null reference (Nothing in Visual Basic).
System..::.InvalidOperationException | source contains no elements.
System..::.AggregateException | One or more exceptions occurred during the evaluation of the query.
System..::.OperationCanceledException | The query was canceled.

See Also

ParallelEnumerable Class
Average Overload
System.Linq Namespace


Average Method (ParallelQuery(Double))

[image]

.NET Framework Class Library
ParallelEnumerable..::.Average Method (ParallelQuery<(Of <(Double>)>))
ParallelEnumerable Class See Also Send Feedback

Computes in parallel the average of a sequence of values.

Namespace: System.Linq
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function Average ( _
    source As ParallelQuery(Of Double) _
) As Double
C#
public static double Average(
    ParallelQuery<double> source
)

Parameters

source
Type: System.Linq..::.ParallelQuery <(Of <(Double>)>)
A sequence of values that are used to calculate an average.

Return Value

The average of the sequence of values.

Exceptions

Exception | Condition
System..::.ArgumentNullException | source is a null reference (Nothing in Visual Basic).
System..::.InvalidOperationException | source contains no elements.
System..::.AggregateException | One or more exceptions occurred during the evaluation of the query.
System..::.OperationCanceledException | The query was canceled.

See Also

ParallelEnumerable Class
Average Overload
System.Linq Namespace


Average Method (ParallelQuery(Int32))

[image]

.NET Framework Class Library
ParallelEnumerable..::.Average Method (ParallelQuery<(Of <(Int32>)>))
ParallelEnumerable Class See Also Send Feedback

Computes in parallel the average of a sequence of values.

Namespace: System.Linq
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function Average ( _
    source As ParallelQuery(Of Integer) _
) As Double
C#
public static double Average(
    ParallelQuery<int> source
)

Parameters

source
Type: System.Linq..::.ParallelQuery <(Of <(Int32>)>)
A sequence of values that are used to calculate an average.

Return Value

The average of the sequence of values.

Exceptions

Exception | Condition
System..::.ArgumentNullException | source is a null reference (Nothing in Visual Basic).
System..::.InvalidOperationException | source contains no elements.
System..::.AggregateException | The sum or count of the elements in the sequence is larger than MaxValue()()(). -or- One or more exceptions occurred during the evaluation of the query.
System..::.OperationCanceledException | The query was canceled.

See Also

ParallelEnumerable Class
Average Overload
System.Linq Namespace


Average Method (ParallelQuery(Int64))

[image]

.NET Framework Class Library
ParallelEnumerable..::.Average Method (ParallelQuery<(Of <(Int64>)>))
ParallelEnumerable Class See Also Send Feedback

Computes in parallel the average of a sequence of values.

Namespace: System.Linq
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function Average ( _
    source As ParallelQuery(Of Long) _
) As Double
C#
public static double Average(
    ParallelQuery<long> source
)

Parameters

source
Type: System.Linq..::.ParallelQuery <(Of <(Int64>)>)
A sequence of values that are used to calculate an average.

Return Value

The average of the sequence of values.

Exceptions

Exception | Condition
System..::.ArgumentNullException | source is a null reference (Nothing in Visual Basic).
System..::.InvalidOperationException | source contains no elements.
System..::.AggregateException | The sum or count of the elements in the sequence is larger than MaxValue()()(). -or- One or more exceptions occurred during the evaluation of the query.
System..::.OperationCanceledException | The query was canceled.

See Also

ParallelEnumerable Class
Average Overload
System.Linq Namespace


Average Method (ParallelQuery(Nullable(Decimal)))

[image]

.NET Framework Class Library
ParallelEnumerable..::.Average Method (ParallelQuery<(Of <(Nullable<(Of <(Decimal>)>)>)>))
ParallelEnumerable Class See Also Send Feedback

Computes in parallel the average of a sequence of values.

Namespace: System.Linq
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function Average ( _
    source As ParallelQuery(Of Nullable(Of Decimal)) _
) As Nullable(Of Decimal)
C#
public static Nullable<decimal> Average(
    ParallelQuery<Nullable<decimal>> source
)

Parameters

source
Type: System.Linq..::.ParallelQuery <(Of <(Nullable<(Of <(Decimal>)>)>)>)
A sequence of values that are used to calculate an average.

Return Value

The average of the sequence of values.

Exceptions

Exception | Condition
System..::.ArgumentNullException | source is a null reference (Nothing in Visual Basic).
System..::.AggregateException | One or more exceptions occurred during the evaluation of the query.
System..::.OperationCanceledException | The query was canceled.

See Also

ParallelEnumerable Class
Average Overload
System.Linq Namespace


Average Method (ParallelQuery(Nullable(Double)))

[image]

.NET Framework Class Library
ParallelEnumerable..::.Average Method (ParallelQuery<(Of <(Nullable<(Of <(Double>)>)>)>))
ParallelEnumerable Class See Also Send Feedback

Computes in parallel the average of a sequence of values.

Namespace: System.Linq
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function Average ( _
    source As ParallelQuery(Of Nullable(Of Double)) _
) As Nullable(Of Double)
C#
public static Nullable<double> Average(
    ParallelQuery<Nullable<double>> source
)

Parameters

source
Type: System.Linq..::.ParallelQuery <(Of <(Nullable<(Of <(Double>)>)>)>)

Exceptions

Exception | Condition
System..::.ArgumentNullException A sequence of values that are used to calculate an average.

Return Value

The average of the sequence of values. source is a null reference (Nothing in Visual Basic).
System..::.AggregateException | One or more exceptions occurred during the evaluation of the query.
System..::.OperationCanceledException | The query was canceled.

See Also

ParallelEnumerable Class
Average Overload
System.Linq Namespace


Average Method (ParallelQuery(Nullable(Int32)))

[image]

.NET Framework Class Library
ParallelEnumerable..::.Average Method (ParallelQuery<(Of <(Nullable<(Of <(Int32>)>)>)>))
ParallelEnumerable Class See Also Send Feedback

Computes in parallel the average of a sequence of values.

Namespace: System.Linq
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function Average ( _
    source As ParallelQuery(Of Nullable(Of Integer)) _
) As Nullable(Of Double)
C#
public static Nullable<double> Average(
    ParallelQuery<Nullable<int>> source
)

Parameters

source
Type: System.Linq..::.ParallelQuery <(Of <(Nullable<(Of <(Int32>)>)>)>)
A sequence of values that are used to calculate an average.

Return Value

The average of the sequence of values.

Exceptions

Exception | Condition
System..::.ArgumentNullException | source is a null reference (Nothing in Visual Basic).
System..::.AggregateException | The sum or count of the elements in the sequence is larger than MaxValue()()(). -or- One or more exceptions occurred during the evaluation of the query.
System..::.OperationCanceledException | The query was canceled.

See Also

ParallelEnumerable Class
Average Overload
System.Linq Namespace


Average Method (ParallelQuery(Nullable(Int64)))

[image]

.NET Framework Class Library
ParallelEnumerable..::.Average Method (ParallelQuery<(Of <(Nullable<(Of <(Int64>)>)>)>))
ParallelEnumerable Class See Also Send Feedback

Computes in parallel the average of a sequence of values.

Namespace: System.Linq
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function Average ( _
    source As ParallelQuery(Of Nullable(Of Long)) _
) As Nullable(Of Double)
C#
public static Nullable<double> Average(
    ParallelQuery<Nullable<long>> source
)

Parameters

source
Type: System.Linq..::.ParallelQuery <(Of <(Nullable<(Of <(Int64>)>)>)>)
A sequence of values that are used to calculate an average.

Return Value

The average of the sequence of values.

Exceptions

Exception | Condition
System..::.ArgumentNullException | source is a null reference (Nothing in Visual Basic).
System..::.AggregateException | The sum or count of the elements in the sequence is larger than MaxValue()()(). -or- One or more exceptions occurred during the evaluation of the query.
System..::.OperationCanceledException | The query was canceled.

See Also

ParallelEnumerable Class
Average Overload
System.Linq Namespace


Average Method (ParallelQuery(Nullable(Single)))

[image]

.NET Framework Class Library
ParallelEnumerable..::.Average Method (ParallelQuery<(Of <(Nullable<(Of <(Single>)>)>)>))
ParallelEnumerable Class See Also Send Feedback

Computes in parallel the average of a sequence of values.

Namespace: System.Linq
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function Average ( _
    source As ParallelQuery(Of Nullable(Of Single)) _
) As Nullable(Of Single)
C#
public static Nullable<float> Average(
    ParallelQuery<Nullable<float>> source
)

Parameters

source
Type: System.Linq..::.ParallelQuery <(Of <(Nullable<(Of <(Single>)>)>)>)
A sequence of values that are used to calculate an average.

Return Value

The average of the sequence of values.

Exceptions

Exception | Condition
System..::.ArgumentNullException | source is a null reference (Nothing in Visual Basic).
System..::.AggregateException | One or more exceptions occurred during the evaluation of the query.
System..::.OperationCanceledException | The query was canceled.

See Also

ParallelEnumerable Class
Average Overload
System.Linq Namespace


Average Method (ParallelQuery(Single))

[image]

.NET Framework Class Library
ParallelEnumerable..::.Average Method (ParallelQuery<(Of <(Single>)>))
ParallelEnumerable Class See Also Send Feedback

Computes in parallel the average of a sequence of values.

Namespace: System.Linq
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function Average ( _
    source As ParallelQuery(Of Single) _
) As Single
C#
public static float Average(
    ParallelQuery<float> source
)

Parameters

source
Type: System.Linq..::.ParallelQuery <(Of <(Single>)>)
A sequence of values that are used to calculate an average.

Return Value

The average of the sequence of values.

Exceptions

Exception | Condition
System..::.ArgumentNullException | source is a null reference (Nothing in Visual Basic).
System..::.InvalidOperationException | source contains no elements.
System..::.AggregateException | One or more exceptions occurred during the evaluation of the query.
System..::.OperationCanceledException | The query was canceled.

See Also

ParallelEnumerable Class
Average Overload
System.Linq Namespace


Average(TSource) Method (ParallelQuery(TSource), Func(TSource, Decimal))

[image]

.NET Framework Class Library
ParallelEnumerable..::.Average<(Of <(TSource>)>) Method (ParallelQuery<(Of <(TSource>)>), Func<(Of <(TSource, Decimal>)>))
ParallelEnumerable Class See Also Send Feedback

Computes in parallel the average of a sequence of values that are obtained by invoking a transform function on each element of the input sequence.

Namespace: System.Linq
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function Average(Of TSource) ( _
    source As ParallelQuery(Of TSource), _
    selector As Func(Of TSource, Decimal) _
) As Decimal
C#
public static decimal Average<TSource>(
    ParallelQuery<TSource> source,
    Func<TSource, decimal> selector
)

Parameters

source
Type: System.Linq..::.ParallelQuery <(Of <(TSource>)>)
A sequence of values that are used to calculate an average.
selector
Type: System..::.Func<(Of <(TSource, Decimal>)>)
A transform function to apply to each element.

Type Parameters

TSource
The type of elements of source.

Return Value

The average of the sequence of values.

Exceptions

Exception | Condition
System..::.ArgumentNullException | source or selector is a null reference (Nothing in Visual Basic).
System..::.InvalidOperationException | source contains no elements.
System..::.AggregateException | One or more exceptions occurred during the evaluation of the query.
System..::.OperationCanceledException | The query was canceled.

See Also

ParallelEnumerable Class
Average Overload
System.Linq Namespace


Average(TSource) Method (ParallelQuery(TSource), Func(TSource, Double))

[image]

.NET Framework Class Library
ParallelEnumerable..::.Average<(Of <(TSource>)>) Method (ParallelQuery<(Of <(TSource>)>), Func<(Of <(TSource, Double>)>))
ParallelEnumerable Class See Also Send Feedback

Computes in parallel the average of a sequence of values that are obtained by invoking a transform function on each element of the input sequence.

Namespace: System.Linq
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function Average(Of TSource) ( _
    source As ParallelQuery(Of TSource), _
    selector As Func(Of TSource, Double) _
) As Double
C#
public static double Average<TSource>(
    ParallelQuery<TSource> source,
    Func<TSource, double> selector
)

Parameters

source
Type: System.Linq..::.ParallelQuery <(Of <(TSource>)>)
A sequence of values that are used to calculate an average.
selector
Type: System..::.Func<(Of <(TSource, Double>)>)
A transform function to apply to each element.

Type Parameters

TSource
The type of elements of source.

Return Value

The average of the sequence of values.

Exceptions

Exception | Condition
System..::.ArgumentNullException | source or selector is a null reference (Nothing in Visual Basic).
System..::.InvalidOperationException | source contains no elements.
System..::.AggregateException | One or more exceptions occurred during the evaluation of the query.
System..::.OperationCanceledException | The query was canceled.

See Also

ParallelEnumerable Class
Average Overload
System.Linq Namespace


Average(TSource) Method (ParallelQuery(TSource), Func(TSource, Int32))

[image]

.NET Framework Class Library
ParallelEnumerable..::.Average<(Of <(TSource>)>) Method (ParallelQuery<(Of <(TSource>)>), Func<(Of <(TSource, Int32>)>))
ParallelEnumerable Class See Also Send Feedback

Computes in parallel the average of a sequence of values that are obtained by invoking a transform function on each element of the input sequence.

Namespace: System.Linq
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function Average(Of TSource) ( _
    source As ParallelQuery(Of TSource), _
    selector As Func(Of TSource, Integer) _
) As Double
C#
public static double Average<TSource>(
    ParallelQuery<TSource> source,
    Func<TSource, int> selector
)

Parameters

source
Type: System.Linq..::.ParallelQuery <(Of <(TSource>)>)
A sequence of values that are used to calculate an average.
selector
Type: System..::.Func<(Of <(TSource, Int32>)>)
A transform function to apply to each element.

Type Parameters

TSource
The type of elements of source.

Return Value

The average of the sequence of values.

Exceptions

Exception | Condition
System..::.ArgumentNullException | source or selector is a null reference (Nothing in Visual Basic).
System..::.InvalidOperationException | source contains no elements.
System..::.AggregateException | The sum or count of the elements in the sequence is larger than MaxValue()()(). -or- One or more exceptions occurred during the evaluation of the query.
System..::.OperationCanceledException | The query was canceled.

See Also

ParallelEnumerable Class
Average Overload
System.Linq Namespace


Average(TSource) Method (ParallelQuery(TSource), Func(TSource, Int64))

[image]

.NET Framework Class Library
ParallelEnumerable..::.Average<(Of <(TSource>)>) Method (ParallelQuery<(Of <(TSource>)>), Func<(Of <(TSource, Int64>)>))
ParallelEnumerable Class See Also Send Feedback

Computes in parallel the average of a sequence of values that are obtained by invoking a transform function on each element of the input sequence.

Namespace: System.Linq
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function Average(Of TSource) ( _
    source As ParallelQuery(Of TSource), _
    selector As Func(Of TSource, Long) _
) As Double
C#
public static double Average<TSource>(
    ParallelQuery<TSource> source,
    Func<TSource, long> selector
)

Parameters

source
Type: System.Linq..::.ParallelQuery <(Of <(TSource>)>)
A sequence of values that are used to calculate an average.
selector
Type: System..::.Func<(Of <(TSource, Int64>)>)
A transform function to apply to each element.

Type Parameters

TSource
The type of elements of source.

Return Value

The average of the sequence of values.

Exceptions

Exception | Condition
System..::.ArgumentNullException | source or selector is a null reference (Nothing in Visual Basic).
System..::.InvalidOperationException | source contains no elements.
System..::.AggregateException | The sum or count of the elements in the sequence is larger than MaxValue()()(). -or- One or more exceptions occurred during the evaluation of the query.
System..::.OperationCanceledException | The query was canceled.

See Also

ParallelEnumerable Class
Average Overload
System.Linq Namespace


Average(TSource) Method (ParallelQuery(TSource), Func(TSource, Nullable(Decimal)))

[image]

.NET Framework Class Library
ParallelEnumerable..::.Average<(Of <(TSource>)>) Method (ParallelQuery<(Of <(TSource>)>), Func<(Of <(TSource, Nullable<(Of <(Decimal>)>)>)>))
ParallelEnumerable Class See Also Send Feedback

Computes in parallel the average of a sequence of values that are obtained by invoking a transform function on each element of the input sequence.

Namespace: System.Linq
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function Average(Of TSource) ( _
    source As ParallelQuery(Of TSource), _
    selector As Func(Of TSource, Nullable(Of Decimal)) _
) As Nullable(Of Decimal)
C#
public static Nullable<decimal> Average<TSource>(
    ParallelQuery<TSource> source,
    Func<TSource, Nullable<decimal>> selector
)

Parameters

source
Type: System.Linq..::.ParallelQuery <(Of <(TSource>)>)
A sequence of values that are used to calculate an average.
selector
Type: System..::.Func<(Of <(TSource, Nullable<(Of <(Decimal>)>)>)>)
A transform function to apply to each element.

Type Parameters

TSource
The type of elements of source.

Return Value

The average of the sequence of values.

Exceptions

Exception | Condition
System..::.ArgumentNullException | source or selector is a null reference (Nothing in Visual Basic).
System..::.AggregateException | One or more exceptions occurred during the evaluation of the query.
System..::.OperationCanceledException | The query was canceled.

See Also

ParallelEnumerable Class
Average Overload
System.Linq Namespace


Average(TSource) Method (ParallelQuery(TSource), Func(TSource, Nullable(Double)))

[image]

.NET Framework Class Library
ParallelEnumerable..::.Average<(Of <(TSource>)>) Method (ParallelQuery<(Of <(TSource>)>), Func<(Of <(TSource, Nullable<(Of <(Double>)>)>)>))
ParallelEnumerable Class See Also Send Feedback

Computes in parallel the average of a sequence of values that are obtained by invoking a transform function on each element of the input sequence.

Namespace: System.Linq
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function Average(Of TSource) ( _
    source As ParallelQuery(Of TSource), _
    selector As Func(Of TSource, Nullable(Of Double)) _
) As Nullable(Of Double)
C#
public static Nullable<double> Average<TSource>(
    ParallelQuery<TSource> source,
    Func<TSource, Nullable<double>> selector
)

Parameters

source
Type: System.Linq..::.ParallelQuery <(Of <(TSource>)>)
A sequence of values that are used to calculate an average.
selector
Type: System..::.Func<(Of <(TSource, Nullable<(Of <(Double>)>)>)>)
A transform function to apply to each element.

Type Parameters

TSource
The type of elements of source.

Return Value

The average of the sequence of values.

Exceptions

Exception | Condition
System..::.ArgumentNullException | source or selector is a null reference (Nothing in Visual Basic).
System..::.AggregateException | One or more exceptions occurred during the evaluation of the query.
System..::.OperationCanceledException | The query was canceled.

See Also

ParallelEnumerable Class
Average Overload
System.Linq Namespace


Average(TSource) Method (ParallelQuery(TSource), Func(TSource, Nullable(Int32)))

[image]

.NET Framework Class Library
ParallelEnumerable..::.Average<(Of <(TSource>)>) Method (ParallelQuery<(Of <(TSource>)>), Func<(Of <(TSource, Nullable<(Of <(Int32>)>)>)>))
ParallelEnumerable Class See Also Send Feedback

Computes in parallel the average of a sequence of values that are obtained by invoking a transform function on each element of the input sequence.

Namespace: System.Linq
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function Average(Of TSource) ( _
    source As ParallelQuery(Of TSource), _
    selector As Func(Of TSource, Nullable(Of Integer)) _
) As Nullable(Of Double)
C#
public static Nullable<double> Average<TSource>(
    ParallelQuery<TSource> source,
    Func<TSource, Nullable<int>> selector
)

Parameters

source
Type: System.Linq..::.ParallelQuery <(Of <(TSource>)>)
A sequence of values that are used to calculate an average.
selector
Type: System..::.Func<(Of <(TSource, Nullable<(Of <(Int32>)>)>)>)
A transform function to apply to each element.

Type Parameters

TSource
The type of elements of source.

Return Value

The average of the sequence of values.

Exceptions

Exception | Condition
System..::.ArgumentNullException | source or selector is a null reference (Nothing in Visual Basic).
System..::.AggregateException | The sum or count of the elements in the sequence is larger than MaxValue()()(). -or- One or more exceptions occurred during the evaluation of the query.
System..::.OperationCanceledException | The query was canceled.

See Also

ParallelEnumerable Class
Average Overload
System.Linq Namespace


Average(TSource) Method (ParallelQuery(TSource), Func(TSource, Nullable(Int64)))

[image]

.NET Framework Class Library
ParallelEnumerable..::.Average<(Of <(TSource>)>) Method (ParallelQuery<(Of <(TSource>)>), Func<(Of <(TSource, Nullable<(Of <(Int64>)>)>)>))
ParallelEnumerable Class See Also Send Feedback

Computes in parallel the average of a sequence of values that are obtained by invoking a transform function on each element of the input sequence.

Namespace: System.Linq
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function Average(Of TSource) ( _
    source As ParallelQuery(Of TSource), _
    selector As Func(Of TSource, Nullable(Of Long)) _
) As Nullable(Of Double)
C#
public static Nullable<double> Average<TSource>(
    ParallelQuery<TSource> source,
    Func<TSource, Nullable<long>> selector
)

Parameters

source
Type: System.Linq..::.ParallelQuery <(Of <(TSource>)>)
A sequence of values that are used to calculate an average.
selector
Type: System..::.Func<(Of <(TSource, Nullable<(Of <(Int64>)>)>)>)
A transform function to apply to each element.

Type Parameters

TSource
The type of elements of source.

Return Value

The average of the sequence of values.

Exceptions

Exception | Condition
System..::.ArgumentNullException | source or selector is a null reference (Nothing in Visual Basic).
System..::.AggregateException | The sum or count of the elements in the sequence is larger than MaxValue()()(). -or- One or more exceptions occurred during the evaluation of the query.
System..::.OperationCanceledException | The query was canceled.

See Also

ParallelEnumerable Class
Average Overload
System.Linq Namespace


Average(TSource) Method (ParallelQuery(TSource), Func(TSource, Nullable(Single)))

[image]

.NET Framework Class Library
ParallelEnumerable..::.Average<(Of <(TSource>)>) Method (ParallelQuery<(Of <(TSource>)>), Func<(Of <(TSource, Nullable<(Of <(Single>)>)>)>))
ParallelEnumerable Class See Also Send Feedback

Computes in parallel the average of a sequence of values that are obtained by invoking a transform function on each element of the input sequence.

Namespace: System.Linq
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function Average(Of TSource) ( _
    source As ParallelQuery(Of TSource), _
    selector As Func(Of TSource, Nullable(Of Single)) _
) As Nullable(Of Single)
C#
public static Nullable<float> Average<TSource>(
    ParallelQuery<TSource> source,
    Func<TSource, Nullable<float>> selector
)

Parameters

source
Type: System.Linq..::.ParallelQuery <(Of <(TSource>)>)
A sequence of values that are used to calculate an average.
selector
Type: System..::.Func<(Of <(TSource, Nullable<(Of <(Single>)>)>)>)
A transform function to apply to each element.

Type Parameters

TSource
The type of elements of source.

Return Value

The average of the sequence of values.

Exceptions

Exception | Condition
System..::.ArgumentNullException | source or selector is a null reference (Nothing in Visual Basic).
System..::.AggregateException | One or more exceptions occurred during the evaluation of the query.
System..::.OperationCanceledException | The query was canceled.

See Also

ParallelEnumerable Class
Average Overload
System.Linq Namespace


Average(TSource) Method (ParallelQuery(TSource), Func(TSource, Single))

[image]

.NET Framework Class Library
ParallelEnumerable..::.Average<(Of <(TSource>)>) Method (ParallelQuery<(Of <(TSource>)>), Func<(Of <(TSource, Single>)>))
ParallelEnumerable Class See Also Send Feedback

Computes in parallel the average of a sequence of values that are obtained by invoking a transform function on each element of the input sequence.

Namespace: System.Linq
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function Average(Of TSource) ( _
    source As ParallelQuery(Of TSource), _
    selector As Func(Of TSource, Single) _
) As Single
C#
public static float Average<TSource>(
    ParallelQuery<TSource> source,
    Func<TSource, float> selector
)

Parameters

source
Type: System.Linq..::.ParallelQuery <(Of <(TSource>)>)
A sequence of values that are used to calculate an average.
selector
Type: System..::.Func<(Of <(TSource, Single>)>)
A transform function to apply to each element.

Type Parameters

TSource
The type of elements of source.

Return Value

The average of the sequence of values.

Exceptions

Exception | Condition
System..::.ArgumentNullException | source or selector is a null reference (Nothing in Visual Basic).
System..::.InvalidOperationException | source contains no elements.
System..::.AggregateException | One or more exceptions occurred during the evaluation of the query.
System..::.OperationCanceledException | The query was canceled.

See Also

ParallelEnumerable Class
Average Overload
System.Linq Namespace


Cast(TResult) Method

[image]

.NET Framework Class Library
ParallelEnumerable..::.Cast<(Of <(TResult>)>) Method
ParallelEnumerable Class See Also Send Feedback

Converts the elements of a ParallelQuery to the specified type.

Namespace: System.Linq
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function Cast(Of TResult) ( _
    source As ParallelQuery _
) As ParallelQuery(Of TResult)
C#
public static ParallelQuery<TResult> Cast<TResult>(
    ParallelQuery source
)

Parameters

source
Type: System.Linq..::.ParallelQuery
The sequence that contains the elements to be converted.

Type Parameters

TResult
The type to convert the elements of source to.

Return Value

A sequence that contains each element of the source sequence converted to the specified type.

Exceptions

Exception | Condition
System..::.ArgumentNullException | source is a null reference (Nothing in Visual Basic).

See Also

ParallelEnumerable Class
System.Linq Namespace


Concat Method

[image] [image]

.NET Framework Class Library
ParallelEnumerable..::.Concat Method
ParallelEnumerable Class See Also Send Feedback

Overload List

Name | Description
Concat<(Of <(TSource>)>)(ParallelQuery<(Of <(TSource>)>), IEnumerable<(Of <(TSource>)>)) | Obsolete. This Concat overload should never be called. This method is marked as obsolete and always throws NotSupportedException when called.
Concat<(Of <(TSource>)>)(ParallelQuery<(Of <(TSource>)>), ParallelQuery<(Of <(TSource>)>)) | Concatenates two parallel sequences.

See Also

ParallelEnumerable Class
System.Linq Namespace


Concat(TSource) Method (ParallelQuery(TSource), IEnumerable(TSource))

[image]

.NET Framework Class Library
ParallelEnumerable..::.Concat<(Of <(TSource>)>) Method (ParallelQuery<(Of <(TSource>)>), IEnumerable<(Of <(TSource>)>))
ParallelEnumerable Class See Also Send Feedback

This Concat overload should never be called. This method is marked as obsolete and always throws NotSupportedException when called.

Namespace: System.Linq
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
<ObsoleteAttribute("The second data source of a binary operator must be of type System.Linq.ParallelQuery<T> rather than System.Collections.Generic.IEnumerable<T>. To fix this problem, use the AsParallel() extension method to convert the right data source to System.Linq.ParallelQuery<T>.")> _
Public Shared Function Concat(Of TSource) ( _
    first As ParallelQuery(Of TSource), _
    second As IEnumerable(Of TSource) _
) As ParallelQuery(Of TSource)
C#
[ObsoleteAttribute("The second data source of a binary operator must be of type System.Linq.ParallelQuery<T> rather than System.Collections.Generic.IEnumerable<T>. To fix this problem, use the AsParallel() extension method to convert the right data source to System.Linq.ParallelQuery<T>.")]
public static ParallelQuery<TSource> Concat<TSource>(
    ParallelQuery<TSource> first,
    IEnumerable<TSource> second
)

Parameters

first
Type: System.Linq..::.ParallelQuery <(Of <(TSource>)>)
This parameter is not used.
second
Type: System.Collections.Generic..::.IEnumerable<(Of <(TSource>)>)
This parameter is not used.

Type Parameters

TSource
This type parameter is not used.

Return Value

This overload always throws a NotSupportedException.

Remarks

This overload exists to disallow usage of Concat with a left data source of type ParallelQuery<(Of <(TSource>)>) and a right data source of type IEnumerable<(Of <(T>)>). Otherwise, the Concat operator would appear to be binding to the parallel implementation, but would in reality bind to the sequential implementation.

Exceptions

Exception | Condition
System..::.NotSupportedException | The exception that occurs when this method is called.

See Also

ParallelEnumerable Class
Concat Overload
System.Linq Namespace


Concat(TSource) Method (ParallelQuery(TSource), ParallelQuery(TSource))

[image]

.NET Framework Class Library
ParallelEnumerable..::.Concat<(Of <(TSource>)>) Method (ParallelQuery<(Of <(TSource>)>), ParallelQuery<(Of <(TSource>)>))
ParallelEnumerable Class See Also Send Feedback

Concatenates two parallel sequences.

Namespace: System.Linq
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function Concat(Of TSource) ( _
    first As ParallelQuery(Of TSource), _
    second As ParallelQuery(Of TSource) _
) As ParallelQuery(Of TSource)
C#
public static ParallelQuery<TSource> Concat<TSource>(
    ParallelQuery<TSource> first,
    ParallelQuery<TSource> second
)

Parameters

first
Type: System.Linq..::.ParallelQuery <(Of <(TSource>)>)
The first sequence to concatenate.
second
Type: System.Linq..::.ParallelQuery <(Of <(TSource>)>)
The sequence to concatenate to the first sequence.

Type Parameters

TSource
The type of the elements of the input sequences.

Return Value

A sequence that contains the concatenated elements of the two input sequences.

Exceptions

Exception | Condition
System..::.ArgumentNullException | first or second is a null reference (Nothing in Visual Basic).

See Also

ParallelEnumerable Class
Concat Overload
System.Linq Namespace


Contains Method

[image] [image]

.NET Framework Class Library
ParallelEnumerable..::.Contains Method
ParallelEnumerable Class See Also Send Feedback

Overload List

Name | Description
Contains<(Of <(TSource>)>)(ParallelQuery<(Of <(TSource>)>), TSource) | Determines in parallel whether a sequence contains a specified element by using the default equality comparer.
Contains<(Of <(TSource>)>)(ParallelQuery<(Of <(TSource>)>), TSource, IEqualityComparer<(Of <(TSource>)>)) | Determines in parallel whether a sequence contains a specified element by using a specified IEqualityComparer{T}.

See Also

ParallelEnumerable Class
System.Linq Namespace


Contains(TSource) Method (ParallelQuery(TSource), TSource)

[image]

.NET Framework Class Library
ParallelEnumerable..::.Contains<(Of <(TSource>)>) Method (ParallelQuery<(Of <(TSource>)>), TSource)
ParallelEnumerable Class See Also Send Feedback

Determines in parallel whether a sequence contains a specified element by using the default equality comparer.

Namespace: System.Linq
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function Contains(Of TSource) ( _
    source As ParallelQuery(Of TSource), _
    value As TSource _
) As Boolean
C#
public static bool Contains<TSource>(
    ParallelQuery<TSource> source,
    TSource value
)

Parameters

source
Type: System.Linq..::.ParallelQuery <(Of <(TSource>)>)
A sequence in which to locate a value.
value
Type: TSource
The value to locate in the sequence.

Type Parameters

TSource
The type of elements of source.

Return Value

true if the source sequence contains an element that has the specified value; otherwise, false.

Exceptions

Exception | Condition
System..::.ArgumentNullException | source is a null reference (Nothing in Visual Basic).
System..::.AggregateException | One or more exceptions occurred during the evaluation of the query.
System..::.OperationCanceledException | The query was canceled.

See Also

ParallelEnumerable Class
Contains Overload
System.Linq Namespace


Contains(TSource) Method (ParallelQuery(TSource), TSource, IEqualityComparer(TSource))

[image]

.NET Framework Class Library
ParallelEnumerable..::.Contains<(Of <(TSource>)>) Method (ParallelQuery<(Of <(TSource>)>), TSource, IEqualityComparer<(Of <(TSource>)>))
ParallelEnumerable Class See Also Send Feedback

Determines in parallel whether a sequence contains a specified element by using a specified IEqualityComparer{T}.

Namespace: System.Linq
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function Contains(Of TSource) ( _
    source As ParallelQuery(Of TSource), _
    value As TSource, _
    comparer As IEqualityComparer(Of TSource) _
) As Boolean
C#
public static bool Contains<TSource>(
    ParallelQuery<TSource> source,
    TSource value,
    IEqualityComparer<TSource> comparer
)

Parameters

source
Type: System.Linq..::.ParallelQuery <(Of <(TSource>)>)
A sequence in which to locate a value.
value
Type: TSource
The value to locate in the sequence.
comparer
Type: System.Collections.Generic..::.IEqualityComparer<(Of <(TSource>)>)
An equality comparer to compare values.

Type Parameters

TSource
The type of elements of source.

Return Value

true if the source sequence contains an element that has the specified value; otherwise, false.

Exceptions

Exception | Condition
System..::.ArgumentNullException | source is a null reference (Nothing in Visual Basic).
System..::.AggregateException | One or more exceptions occurred during the evaluation of the query.
System..::.OperationCanceledException | The query was canceled.

See Also

ParallelEnumerable Class
Contains Overload
System.Linq Namespace


Count Method

[image] [image]

.NET Framework Class Library
ParallelEnumerable..::.Count Method
ParallelEnumerable Class See Also Send Feedback

Overload List

Name | Description
Count<(Of <(TSource>)>)(ParallelQuery<(Of <(TSource>)>)) | Returns the number of elements in a parallel sequence.
Count<(Of <(TSource>)>)(ParallelQuery<(Of <(TSource>)>), Func<(Of <(TSource, Boolean>)>)) | Returns a number that represents how many elements in the specified parallel sequence satisfy a condition.

See Also

ParallelEnumerable Class
System.Linq Namespace


Count(TSource) Method (ParallelQuery(TSource))

[image]

.NET Framework Class Library
ParallelEnumerable..::.Count<(Of <(TSource>)>) Method (ParallelQuery<(Of <(TSource>)>))
ParallelEnumerable Class See Also Send Feedback

Returns the number of elements in a parallel sequence.

Namespace: System.Linq
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function Count(Of TSource) ( _
    source As ParallelQuery(Of TSource) _
) As Integer
C#
public static int Count<TSource>(
    ParallelQuery<TSource> source
)

Parameters

source
Type: System.Linq..::.ParallelQuery <(Of <(TSource>)>)
A sequence that contains elements to be counted.

Type Parameters

TSource
The type of the elements of source.

Return Value

The number of elements in the input sequence.

Exceptions

Exception | Condition
System..::.ArgumentNullException | source is a null reference (Nothing in Visual Basic).
System..::.AggregateException | The number of elements in source is larger than MaxValue()()(). -or- One or more exceptions occurred during the evaluation of the query.
System..::.OperationCanceledException | The query was canceled.

See Also

ParallelEnumerable Class
Count Overload
System.Linq Namespace


Count(TSource) Method (ParallelQuery(TSource), Func(TSource, Boolean))

[image]

.NET Framework Class Library
ParallelEnumerable..::.Count<(Of <(TSource>)>) Method (ParallelQuery<(Of <(TSource>)>), Func<(Of <(TSource, Boolean>)>))
ParallelEnumerable Class See Also Send Feedback

Returns a number that represents how many elements in the specified parallel sequence satisfy a condition.

Namespace: System.Linq
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function Count(Of TSource) ( _
    source As ParallelQuery(Of TSource), _
    predicate As Func(Of TSource, Boolean) _
) As Integer
C#
public static int Count<TSource>(
    ParallelQuery<TSource> source,
    Func<TSource, bool> predicate
)

Parameters

source
Type: System.Linq..::.ParallelQuery <(Of <(TSource>)>)
A sequence that contains elements to be counted.
predicate
Type: System..::.Func<(Of <(TSource, Boolean>)>)
A function to test each element for a condition.

Type Parameters

TSource
The type of the elements of source.

Return Value

A number that represents how many elements in the sequence satisfy the condition in the predicate function.

Exceptions

Exception | Condition
System..::.ArgumentNullException | source or predicate is a null reference (Nothing in Visual Basic).
System..::.AggregateException | The number of elements in source is larger than MaxValue()()(). -or- One or more exceptions occurred during the evaluation of the query.
System..::.OperationCanceledException | The query was canceled.

See Also

ParallelEnumerable Class
Count Overload
System.Linq Namespace


DefaultIfEmpty Method

[image] [image]

.NET Framework Class Library
ParallelEnumerable..::.DefaultIfEmpty Method
ParallelEnumerable Class See Also Send Feedback

Overload List

Name | Description
DefaultIfEmpty<(Of <(TSource>)>)(ParallelQuery<(Of <(TSource>)>)) | Returns the elements of the specified parallel sequence or the type parameter's default value in a singleton collection if the sequence is empty.
DefaultIfEmpty<(Of <(TSource>)>)(ParallelQuery<(Of <(TSource>)>), TSource) | Returns the elements of the specified parallel sequence or the specified value in a singleton collection if the sequence is empty.

See Also

ParallelEnumerable Class
System.Linq Namespace


DefaultIfEmpty(TSource) Method (ParallelQuery(TSource))

[image]

.NET Framework Class Library
ParallelEnumerable..::.DefaultIfEmpty<(Of <(TSource>)>) Method (ParallelQuery<(Of <(TSource>)>))
ParallelEnumerable Class See Also Send Feedback

Returns the elements of the specified parallel sequence or the type parameter's default value in a singleton collection if the sequence is empty.

Namespace: System.Linq
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function DefaultIfEmpty(Of TSource) ( _
    source As ParallelQuery(Of TSource) _
) As ParallelQuery(Of TSource)
C#
public static ParallelQuery<TSource> DefaultIfEmpty<TSource>(
    ParallelQuery<TSource> source
)

Parameters

source
Type: System.Linq..::.ParallelQuery <(Of <(TSource>)>)
The sequence to return a default value for if it is empty.

Type Parameters

TSource
The type of the elements of source.

Return Value

A sequence that contains default(TSource) if source is empty; otherwise, source.

Exceptions

Exception | Condition
System..::.ArgumentNullException | source is a null reference (Nothing in Visual Basic).

See Also

ParallelEnumerable Class
DefaultIfEmpty Overload
System.Linq Namespace


DefaultIfEmpty(TSource) Method (ParallelQuery(TSource), TSource)

[image]

.NET Framework Class Library
ParallelEnumerable..::.DefaultIfEmpty<(Of <(TSource>)>) Method (ParallelQuery<(Of <(TSource>)>), TSource)
ParallelEnumerable Class See Also Send Feedback

Returns the elements of the specified parallel sequence or the specified value in a singleton collection if the sequence is empty.

Namespace: System.Linq
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function DefaultIfEmpty(Of TSource) ( _
    source As ParallelQuery(Of TSource), _
    defaultValue As TSource _
) As ParallelQuery(Of TSource)
C#
public static ParallelQuery<TSource> DefaultIfEmpty<TSource>(
    ParallelQuery<TSource> source,
    TSource defaultValue
)

Parameters

source
Type: System.Linq..::.ParallelQuery <(Of <(TSource>)>)
The sequence to return the specified value for if it is empty.
defaultValue
Type: TSource
The value to return if the sequence is empty.

Type Parameters

TSource
The type of the elements of source.

Return Value

A sequence that contains defaultValue if source is empty; otherwise, source.

Exceptions

Exception | Condition
System..::.ArgumentNullException | source is a null reference (Nothing in Visual Basic).

See Also

ParallelEnumerable Class
DefaultIfEmpty Overload
System.Linq Namespace


Distinct Method

[image] [image]

.NET Framework Class Library
ParallelEnumerable..::.Distinct Method
ParallelEnumerable Class See Also Send Feedback

Overload List

Name | Description
Distinct<(Of <(TSource>)>)(ParallelQuery<(Of <(TSource>)>)) | Returns distinct elements from a parallel sequence by using the default equality comparer to compare values.
Distinct<(Of <(TSource>)>)(ParallelQuery<(Of <(TSource>)>), IEqualityComparer<(Of <(TSource>)>)) | Returns distinct elements from a parallel sequence by using a specified IEqualityComparer{T} to compare values.

See Also

ParallelEnumerable Class
System.Linq Namespace


Distinct(TSource) Method (ParallelQuery(TSource))

[image]

.NET Framework Class Library
ParallelEnumerable..::.Distinct<(Of <(TSource>)>) Method (ParallelQuery<(Of <(TSource>)>))
ParallelEnumerable Class See Also Send Feedback

Returns distinct elements from a parallel sequence by using the default equality comparer to compare values.

Namespace: System.Linq
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function Distinct(Of TSource) ( _
    source As ParallelQuery(Of TSource) _
) As ParallelQuery(Of TSource)
C#
public static ParallelQuery<TSource> Distinct<TSource>(
    ParallelQuery<TSource> source
)

Parameters

source
Type: System.Linq..::.ParallelQuery <(Of <(TSource>)>)
The sequence to remove duplicate elements from.

Type Parameters

TSource
The type of the elements of source.

Return Value

A sequence that contains distinct elements from the source sequence.

Exceptions

Exception | Condition
System..::.ArgumentNullException | source is a null reference (Nothing in Visual Basic).

See Also

ParallelEnumerable Class
Distinct Overload
System.Linq Namespace


Distinct(TSource) Method (ParallelQuery(TSource), IEqualityComparer(TSource))

[image]

.NET Framework Class Library
ParallelEnumerable..::.Distinct<(Of <(TSource>)>) Method (ParallelQuery<(Of <(TSource>)>), IEqualityComparer<(Of <(TSource>)>))
ParallelEnumerable Class See Also Send Feedback

Returns distinct elements from a parallel sequence by using a specified IEqualityComparer{T} to compare values.

Namespace: System.Linq
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function Distinct(Of TSource) ( _
    source As ParallelQuery(Of TSource), _
    comparer As IEqualityComparer(Of TSource) _
) As ParallelQuery(Of TSource)
C#
public static ParallelQuery<TSource> Distinct<TSource>(
    ParallelQuery<TSource> source,
    IEqualityComparer<TSource> comparer
)

Parameters

source
Type: System.Linq..::.ParallelQuery <(Of <(TSource>)>)
The sequence to remove duplicate elements from.
comparer
Type: System.Collections.Generic..::.IEqualityComparer<(Of <(TSource>)>)
An IEqualityComparer<(Of <(T>)>) to compare values.

Type Parameters

TSource
The type of the elements of source.

Return Value

A sequence that contains distinct elements from the source sequence.

Exceptions

Exception | Condition
System..::.ArgumentNullException | source is a null reference (Nothing in Visual Basic).

See Also

ParallelEnumerable Class
Distinct Overload
System.Linq Namespace


ElementAt(TSource) Method

[image]

.NET Framework Class Library
ParallelEnumerable..::.ElementAt<(Of <(TSource>)>) Method
ParallelEnumerable Class See Also Send Feedback

Returns the element at a specified index in a parallel sequence.

Namespace: System.Linq
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function ElementAt(Of TSource) ( _
    source As ParallelQuery(Of TSource), _
    index As Integer _
) As TSource
C#
public static TSource ElementAt<TSource>(
    ParallelQuery<TSource> source,
    int index
)

Parameters

source
Type: System.Linq..::.ParallelQuery <(Of <(TSource>)>)
A sequence to return an element from.
index
Type: System..::.Int32
The zero-based index of the element to retrieve.

Type Parameters

TSource
The type of the elements of source.

Return Value

The element at the specified position in the source sequence.

Exceptions

Exception | Condition
System..::.ArgumentNullException | source is a null reference (Nothing in Visual Basic).
System..::.ArgumentOutOfRangeException | index is less than 0 or greater than or equal to the number of elements in source.
System..::.AggregateException | One or more exceptions occurred during the evaluation of the query.
System..::.OperationCanceledException | The query was canceled.

See Also

ParallelEnumerable Class
System.Linq Namespace


ElementAtOrDefault(TSource) Method

[image]

.NET Framework Class Library
ParallelEnumerable..::.ElementAtOrDefault<(Of <(TSource>)>) Method
ParallelEnumerable Class See Also Send Feedback

Returns the element at a specified index in a parallel sequence or a default value if the index is out of range.

Namespace: System.Linq
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function ElementAtOrDefault(Of TSource) ( _
    source As ParallelQuery(Of TSource), _
    index As Integer _
) As TSource
C#
public static TSource ElementAtOrDefault<TSource>(
    ParallelQuery<TSource> source,
    int index
)

Parameters

source
Type: System.Linq..::.ParallelQuery <(Of <(TSource>)>)
A sequence to return an element from.
index
Type: System..::.Int32
The zero-based index of the element to retrieve.

Type Parameters

TSource
The type of the elements of source.

Return Value

default(TSource) if the index is outside the bounds of the source sequence; otherwise, the element at the specified position in the source sequence.

Exceptions

Exception | Condition
System..::.ArgumentNullException | source is a null reference (Nothing in Visual Basic).
System..::.AggregateException | One or more exceptions occurred during the evaluation of the query.
System..::.OperationCanceledException | The query was canceled.

See Also

ParallelEnumerable Class
System.Linq Namespace


Empty(TResult) Method

[image]

.NET Framework Class Library
ParallelEnumerable..::.Empty<(Of <(TResult>)>) Method
ParallelEnumerable Class See Also Send Feedback

Returns an empty ParallelQuery{TResult} that has the specified type argument.

Namespace: System.Linq
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function Empty(Of TResult) As ParallelQuery(Of TResult)
C#
public static ParallelQuery<TResult> Empty<TResult>()

Type Parameters

TResult
The type to assign to the type parameter of the returned generic sequence.

Return Value

An empty sequence whose type argument is TResult.

See Also

ParallelEnumerable Class
System.Linq Namespace


Except Method

[image] [image]

.NET Framework Class Library
ParallelEnumerable..::.Except Method
ParallelEnumerable Class See Also Send Feedback

Overload List

Name | Description
Except<(Of <(TSource>)>)(ParallelQuery<(Of <(TSource>)>), IEnumerable<(Of <(TSource>)>)) | Obsolete. This Except overload should never be called. This method is marked as obsolete and always throws NotSupportedException when called.
Except<(Of <(TSource>)>)(ParallelQuery<(Of <(TSource>)>), ParallelQuery<(Of <(TSource>)>)) | Produces the set difference of two parallel sequences by using the default equality comparer to compare values.
Except<(Of <(TSource>)>)(ParallelQuery<(Of <(TSource>)>), IEnumerable<(Of <(TSource>)>), IEqualityComparer<(Of <(TSource>)>)) | Obsolete. This Except overload should never be called. This method is marked as obsolete and always throws NotSupportedException when called.
Except<(Of <(TSource>)>)(ParallelQuery<(Of <(TSource>)>), ParallelQuery<(Of <(TSource>)>), IEqualityComparer<(Of <(TSource>)>)) | Produces the set difference of two parallel sequences by using the specified IEqualityComparer{T} to compare values.

See Also

ParallelEnumerable Class
System.Linq Namespace


Except(TSource) Method (ParallelQuery(TSource), IEnumerable(TSource))

[image]

.NET Framework Class Library
ParallelEnumerable..::.Except<(Of <(TSource>)>) Method (ParallelQuery<(Of <(TSource>)>), IEnumerable<(Of <(TSource>)>))
ParallelEnumerable Class See Also Send Feedback

This Except overload should never be called. This method is marked as obsolete and always throws NotSupportedException when called.

Namespace: System.Linq
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
<ObsoleteAttribute("The second data source of a binary operator must be of type System.Linq.ParallelQuery<T> rather than System.Collections.Generic.IEnumerable<T>. To fix this problem, use the AsParallel() extension method to convert the right data source to System.Linq.ParallelQuery<T>.")> _
Public Shared Function Except(Of TSource) ( _
    first As ParallelQuery(Of TSource), _
    second As IEnumerable(Of TSource) _
) As ParallelQuery(Of TSource)
C#
[ObsoleteAttribute("The second data source of a binary operator must be of type System.Linq.ParallelQuery<T> rather than System.Collections.Generic.IEnumerable<T>. To fix this problem, use the AsParallel() extension method to convert the right data source to System.Linq.ParallelQuery<T>.")]
public static ParallelQuery<TSource> Except<TSource>(
    ParallelQuery<TSource> first,
    IEnumerable<TSource> second
)

Parameters

first
Type: System.Linq..::.ParallelQuery <(Of <(TSource>)>)
This parameter is not used.
second
Type: System.Collections.Generic..::.IEnumerable<(Of <(TSource>)>)
This parameter is not used.

Type Parameters

TSource
This type parameter is not used.

Return Value

This overload always throws a NotSupportedException.

Remarks

This overload exists to disallow usage of Except with a left data source of type ParallelQuery<(Of <(TSource>)>) and a right data source of type IEnumerable<(Of <(T>)>). Otherwise, the Except operator would appear to be binding to the parallel implementation, but would in reality bind to the sequential implementation.

Exceptions

Exception | Condition
System..::.NotSupportedException | The exception that occurs when this method is called.

See Also

ParallelEnumerable Class
Except Overload
System.Linq Namespace


Except(TSource) Method (ParallelQuery(TSource), ParallelQuery(TSource))

[image]

.NET Framework Class Library
ParallelEnumerable..::.Except<(Of <(TSource>)>) Method (ParallelQuery<(Of <(TSource>)>), ParallelQuery<(Of <(TSource>)>))
ParallelEnumerable Class See Also Send Feedback

Produces the set difference of two parallel sequences by using the default equality comparer to compare values.

Namespace: System.Linq
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function Except(Of TSource) ( _
    first As ParallelQuery(Of TSource), _
    second As ParallelQuery(Of TSource) _
) As ParallelQuery(Of TSource)
C#
public static ParallelQuery<TSource> Except<TSource>(
    ParallelQuery<TSource> first,
    ParallelQuery<TSource> second
)

Parameters

first
Type: System.Linq..::.ParallelQuery <(Of <(TSource>)>)
A sequence whose elements that are not also in second will be returned.
second
Type: System.Linq..::.ParallelQuery <(Of <(TSource>)>)
A sequence whose elements that also occur in the first sequence will cause those elements to be removed from the returned sequence.

Type Parameters

TSource
The type of the elements of the input sequences.

Return Value

A sequence that contains the set difference of the elements of two sequences.

Exceptions

Exception | Condition
System..::.ArgumentNullException | first or second is a null reference (Nothing in Visual Basic).

See Also

ParallelEnumerable Class
Except Overload
System.Linq Namespace


Except(TSource) Method (ParallelQuery(TSource), IEnumerable(TSource), IEqualityComparer(TSource))

[image]

.NET Framework Class Library
ParallelEnumerable..::.Except<(Of <(TSource>)>) Method (ParallelQuery<(Of <(TSource>)>), IEnumerable<(Of <(TSource>)>), IEqualityComparer<(Of <(TSource>)>))
ParallelEnumerable Class See Also Send Feedback

This Except overload should never be called. This method is marked as obsolete and always throws NotSupportedException when called.

Namespace: System.Linq
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
<ObsoleteAttribute("The second data source of a binary operator must be of type System.Linq.ParallelQuery<T> rather than System.Collections.Generic.IEnumerable<T>. To fix this problem, use the AsParallel() extension method to convert the right data source to System.Linq.ParallelQuery<T>.")> _
Public Shared Function Except(Of TSource) ( _
    first As ParallelQuery(Of TSource), _
    second As IEnumerable(Of TSource), _
    comparer As IEqualityComparer(Of TSource) _
) As ParallelQuery(Of TSource)
C#
[ObsoleteAttribute("The second data source of a binary operator must be of type System.Linq.ParallelQuery<T> rather than System.Collections.Generic.IEnumerable<T>. To fix this problem, use the AsParallel() extension method to convert the right data source to System.Linq.ParallelQuery<T>.")]
public static ParallelQuery<TSource> Except<TSource>(
    ParallelQuery<TSource> first,
    IEnumerable<TSource> second,
    IEqualityComparer<TSource> comparer
)

Parameters

first
Type: System.Linq..::.ParallelQuery <(Of <(TSource>)>)
This parameter is not used.
second
Type: System.Collections.Generic..::.IEnumerable<(Of <(TSource>)>)
This parameter is not used.
comparer
Type: System.Collections.Generic..::.IEqualityComparer<(Of <(TSource>)>)
This parameter is not used.

Type Parameters

TSource
This type parameter is not used.

Return Value

This overload always throws a NotSupportedException.

Remarks

This overload exists to disallow usage of Except with a left data source of type ParallelQuery<(Of <(TSource>)>) and a right data source of type IEnumerable<(Of <(T>)>). Otherwise, the Except operator would appear to be binding to the parallel implementation, but would in reality bind to the sequential implementation.

Exceptions

Exception | Condition
System..::.NotSupportedException | The exception that occurs when this method is called.

See Also

ParallelEnumerable Class
Except Overload
System.Linq Namespace


Except(TSource) Method (ParallelQuery(TSource), ParallelQuery(TSource), IEqualityComparer(TSource))

[image]

.NET Framework Class Library
ParallelEnumerable..::.Except<(Of <(TSource>)>) Method (ParallelQuery<(Of <(TSource>)>), ParallelQuery<(Of <(TSource>)>), IEqualityComparer<(Of <(TSource>)>))
ParallelEnumerable Class See Also Send Feedback

Produces the set difference of two parallel sequences by using the specified IEqualityComparer{T} to compare values.

Namespace: System.Linq
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function Except(Of TSource) ( _
    first As ParallelQuery(Of TSource), _
    second As ParallelQuery(Of TSource), _
    comparer As IEqualityComparer(Of TSource) _
) As ParallelQuery(Of TSource)
C#
public static ParallelQuery<TSource> Except<TSource>(
    ParallelQuery<TSource> first,
    ParallelQuery<TSource> second,
    IEqualityComparer<TSource> comparer
)

Parameters

first
Type: System.Linq..::.ParallelQuery <(Of <(TSource>)>)
A sequence whose elements that are not also in second will be returned.
second
Type: System.Linq..::.ParallelQuery <(Of <(TSource>)>)
A sequence whose elements that also occur in the first sequence will cause those elements to be removed from the returned sequence.
comparer
Type: System.Collections.Generic..::.IEqualityComparer<(Of <(TSource>)>)
An IEqualityComparer<(Of <(T>)>) to compare values.

Type Parameters

TSource
The type of the elements of the input sequences.

Return Value

A sequence that contains the set difference of the elements of two sequences.

Exceptions

Exception | Condition
System..::.ArgumentNullException | first or second is a null reference (Nothing in Visual Basic).

See Also

ParallelEnumerable Class
Except Overload
System.Linq Namespace


First Method

[image] [image]

.NET Framework Class Library
ParallelEnumerable..::.First Method
ParallelEnumerable Class See Also Send Feedback

Overload List

Name | Description
First<(Of <(TSource>)>)(ParallelQuery<(Of <(TSource>)>)) | Returns the first element of a parallel sequence.
First<(Of <(TSource>)>)(ParallelQuery<(Of <(TSource>)>), Func<(Of <(TSource, Boolean>)>)) | Returns the first element in a parallel sequence that satisfies a specified condition.

See Also

ParallelEnumerable Class
System.Linq Namespace


First(TSource) Method (ParallelQuery(TSource))

[image]

.NET Framework Class Library
ParallelEnumerable..::.First<(Of <(TSource>)>) Method (ParallelQuery<(Of <(TSource>)>))
ParallelEnumerable Class See Also Send Feedback

Returns the first element of a parallel sequence.

Namespace: System.Linq
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function First(Of TSource) ( _
    source As ParallelQuery(Of TSource) _
) As TSource
C#
public static TSource First<TSource>(
    ParallelQuery<TSource> source
)

Parameters

source
Type: System.Linq..::.ParallelQuery <(Of <(TSource>)>)
The sequence to return the first element of.

Type Parameters

TSource
The type of the elements of source.

Return Value

The first element in the specified sequence.

Exceptions

Exception | Condition
System..::.ArgumentNullException | source is a null reference (Nothing in Visual Basic).
System..::.InvalidOperationException | source contains no elements.
System..::.AggregateException | One or more exceptions occurred during the evaluation of the query.
System..::.OperationCanceledException | The query was canceled.

See Also

ParallelEnumerable Class
First Overload
System.Linq Namespace


First(TSource) Method (ParallelQuery(TSource), Func(TSource, Boolean))

[image]

.NET Framework Class Library
ParallelEnumerable..::.First<(Of <(TSource>)>) Method (ParallelQuery<(Of <(TSource>)>), Func<(Of <(TSource, Boolean>)>))
ParallelEnumerable Class See Also Send Feedback

Returns the first element in a parallel sequence that satisfies a specified condition.

Namespace: System.Linq
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function First(Of TSource) ( _
    source As ParallelQuery(Of TSource), _
    predicate As Func(Of TSource, Boolean) _
) As TSource
C#
public static TSource First<TSource>(
    ParallelQuery<TSource> source,
    Func<TSource, bool> predicate
)

Parameters

source
Type: System.Linq..::.ParallelQuery <(Of <(TSource>)>)
The sequence to return an element from.
predicate
Type: System..::.Func<(Of <(TSource, Boolean>)>)
A function to test each element for a condition.

Type Parameters

TSource
The type of the elements of source.

Return Value

The first element in the sequence that passes the test in the specified predicate function.

Remarks

There's a temporary difference from LINQ to Objects, this does not throw ArgumentNullException when the predicate is null.

Exceptions

Exception | Condition
System..::.ArgumentNullException | source or predicate is a null reference (Nothing in Visual Basic).
System..::.InvalidOperationException | No element in source satisfies the condition in predicate.
System..::.AggregateException | One or more exceptions occurred during the evaluation of the query.
System..::.OperationCanceledException | The query was canceled.

See Also

ParallelEnumerable Class
First Overload
System.Linq Namespace


FirstOrDefault Method

[image] [image]

.NET Framework Class Library
ParallelEnumerable..::.FirstOrDefault Method
ParallelEnumerable Class See Also Send Feedback

Overload List

Name | Description
FirstOrDefault<(Of <(TSource>)>)(ParallelQuery<(Of <(TSource>)>)) | Returns the first element of a parallel sequence, or a default value if the sequence contains no elements.
FirstOrDefault<(Of <(TSource>)>)(ParallelQuery<(Of <(TSource>)>), Func<(Of <(TSource, Boolean>)>)) | Returns the first element of the parallel sequence that satisfies a condition or a default value if no such element is found.

See Also

ParallelEnumerable Class
System.Linq Namespace


FirstOrDefault(TSource) Method (ParallelQuery(TSource))

[image]

.NET Framework Class Library
ParallelEnumerable..::.FirstOrDefault<(Of <(TSource>)>) Method (ParallelQuery<(Of <(TSource>)>))
ParallelEnumerable Class See Also Send Feedback

Returns the first element of a parallel sequence, or a default value if the sequence contains no elements.

Namespace: System.Linq
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function FirstOrDefault(Of TSource) ( _
    source As ParallelQuery(Of TSource) _
) As TSource
C#
public static TSource FirstOrDefault<TSource>(
    ParallelQuery<TSource> source
)

Parameters

source
Type: System.Linq..::.ParallelQuery <(Of <(TSource>)>)
The sequence to return the first element of.

Type Parameters

TSource
The type of the elements of source.

Return Value

default(TSource) if source is empty; otherwise, the first element in source.

Exceptions

Exception | Condition
System..::.ArgumentNullException | source is a null reference (Nothing in Visual Basic).
System..::.AggregateException | One or more exceptions occurred during the evaluation of the query.
System..::.OperationCanceledException | The query was canceled.

See Also

ParallelEnumerable Class
FirstOrDefault Overload
System.Linq Namespace


FirstOrDefault(TSource) Method (ParallelQuery(TSource), Func(TSource, Boolean))

[image]

.NET Framework Class Library
ParallelEnumerable..::.FirstOrDefault<(Of <(TSource>)>) Method (ParallelQuery<(Of <(TSource>)>), Func<(Of <(TSource, Boolean>)>))
ParallelEnumerable Class See Also Send Feedback

Returns the first element of the parallel sequence that satisfies a condition or a default value if no such element is found.

Namespace: System.Linq
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function FirstOrDefault(Of TSource) ( _
    source As ParallelQuery(Of TSource), _
    predicate As Func(Of TSource, Boolean) _
) As TSource
C#
public static TSource FirstOrDefault<TSource>(
    ParallelQuery<TSource> source,
    Func<TSource, bool> predicate
)

Parameters

source
Type: System.Linq..::.ParallelQuery <(Of <(TSource>)>)
The sequence to return an element from.
predicate
Type: System..::.Func<(Of <(TSource, Boolean>)>)
A function to test each element for a condition.

Type Parameters

TSource
The type of the elements of source.

Return Value

default(TSource) if source is empty or if no element passes the test specified by predicate; otherwise, the first element in source that passes the test specified by predicate.

Remarks

There's a temporary difference from LINQ to Objects, this does not throw ArgumentNullException when the predicate is null.

Exceptions

Exception | Condition
System..::.ArgumentNullException | source or predicate is a null reference (Nothing in Visual Basic).
System..::.AggregateException | One or more exceptions occurred during the evaluation of the query.
System..::.OperationCanceledException | The query was canceled.

See Also

ParallelEnumerable Class
FirstOrDefault Overload
System.Linq Namespace


ForAll(TSource) Method

[image]

.NET Framework Class Library
ParallelEnumerable..::.ForAll<(Of <(TSource>)>) Method
ParallelEnumerable Class See Also Send Feedback

Invokes in parallel the specified action for each element in the source.

Namespace: System.Linq
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Sub ForAll(Of TSource) ( _
    source As ParallelQuery(Of TSource), _
    action As Action(Of TSource) _
)
C#
public static void ForAll<TSource>(
    ParallelQuery<TSource> source,
    Action<TSource> action
)

Parameters

source
Type: System.Linq..::.ParallelQuery <(Of <(TSource>)>)
The ParallelQuery<(Of <(TSource>)>) whose elements will be processed by action.
action
Type: System..::.Action<(Of <(TSource>)>)
An Action to invoke on each element.

Type Parameters

TSource
The type of elements of source.

Remarks

This is an efficient way to process the output from a parallelized query because it does not require a merge step at the end. However, order of execution is non-deterministic.

Exceptions

Exception | Condition
System..::.ArgumentNullException | source or action is a null reference (Nothing in Visual Basic).
System..::.AggregateException | One or more exceptions occurred during the evaluation of the query.
System..::.OperationCanceledException | The query was canceled.

See Also

ParallelEnumerable Class
System.Linq Namespace


GroupBy Method

[image] [image]

.NET Framework Class Library
ParallelEnumerable..::.GroupBy Method
ParallelEnumerable Class See Also Send Feedback

Overload List

Name | Description
GroupBy<(Of <(TSource, TKey>)>)(ParallelQuery<(Of <(TSource>)>), Func<(Of <(TSource, TKey>)>)) | Groups in parallel the elements of a sequence according to a specified key selector function.
GroupBy<(Of <(TSource, TKey>)>)(ParallelQuery<(Of <(TSource>)>), Func<(Of <(TSource, TKey>)>), IEqualityComparer<(Of <(TKey>)>)) | Groups in parallel the elements of a sequence according to a specified key selector function and compares the keys by using a specified comparer.
GroupBy<(Of <(TSource, TKey, TElement>)>)(ParallelQuery<(Of <(TSource>)>), Func<(Of <(TSource, TKey>)>), Func<(Of <(TSource, TElement>)>)) | Groups in parallel the elements of a sequence according to a specified key selector function and projects the elements for each group by using a specified function.
GroupBy<(Of <(TSource, TKey, TResult>)>)(ParallelQuery<(Of <(TSource>)>), Func<(Of <(TSource, TKey>)>), Func<(Of <(TKey, IEnumerable<(Of <(TSource>)>), TResult>)>)) | Groups in parallel the elements of a sequence according to a specified key selector function and creates a result value from each group and its key.
GroupBy<(Of <(TSource, TKey, TElement>)>)(ParallelQuery<(Of <(TSource>)>), Func<(Of <(TSource, TKey>)>), Func<(Of <(TSource, TElement>)>), IEqualityComparer<(Of <(TKey>)>)) | Groups in parallel 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.
GroupBy<(Of <(TSource, TKey, TElement, TResult>)>)(ParallelQuery<(Of <(TSource>)>), Func<(Of <(TSource, TKey>)>), Func<(Of <(TSource, TElement>)>), Func<(Of <(TKey, IEnumerable<(Of <(TElement>)>), TResult>)>)) | Groups in parallel 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.
GroupBy<(Of <(TSource, TKey, TResult>)>)(ParallelQuery<(Of <(TSource>)>), Func<(Of <(TSource, TKey>)>), Func<(Of <(TKey, IEnumerable<(Of <(TSource>)>), TResult>)>), IEqualityComparer<(Of <(TKey>)>)) | Groups in parallel 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.
GroupBy<(Of <(TSource, TKey, TElement, TResult>)>)(ParallelQuery<(Of <(TSource>)>), Func<(Of <(TSource, TKey>)>), Func<(Of <(TSource, TElement>)>), Func<(Of <(TKey, IEnumerable<(Of <(TElement>)>), TResult>)>), IEqualityComparer<(Of <(TKey>)>)) | 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.

See Also

ParallelEnumerable Class
System.Linq Namespace


GroupBy(TSource, TKey) Method (ParallelQuery(TSource), Func(TSource, TKey))

[image]

.NET Framework Class Library
ParallelEnumerable..::.GroupBy<(Of <(TSource, TKey>)>) Method (ParallelQuery<(Of <(TSource>)>), Func<(Of <(TSource, TKey>)>))
ParallelEnumerable Class See Also Send Feedback

Groups in parallel the elements of a sequence according to a specified key selector function.

Namespace: System.Linq
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function GroupBy(Of TSource, TKey) ( _
    source As ParallelQuery(Of TSource), _
    keySelector As Func(Of TSource, TKey) _
) As ParallelQuery(Of IGrouping(Of TKey, TSource))
C#
public static ParallelQuery<IGrouping<TKey, TSource>> GroupBy<TSource, TKey>(
    ParallelQuery<TSource> source,
    Func<TSource, TKey> keySelector
)

Parameters

source
Type: System.Linq..::.ParallelQuery <(Of <(TSource>)>)
An OrderedParallelQuery{TSource}than contains elements to sort.
keySelector
Type: System..::.Func<(Of <(TSource, TKey>)>)
A function to extract a key from an element.

Type Parameters

TSource
The type of elements of source.
TKey
The type of the key returned by keySelector.

Return Value

An OrderedParallelQuery{TSource}whose elements are sorted descending according to a key.

See Also

ParallelEnumerable Class
GroupBy Overload
System.Linq Namespace


GroupBy(TSource, TKey) Method (ParallelQuery(TSource), Func(TSource, TKey), IEqualityComparer(TKey))

[image]

.NET Framework Class Library
ParallelEnumerable..::.GroupBy<(Of <(TSource, TKey>)>) Method (ParallelQuery<(Of <(TSource>)>), Func<(Of <(TSource, TKey>)>), IEqualityComparer<(Of <(TKey>)>))
ParallelEnumerable Class See Also Send Feedback

Groups in parallel the elements of a sequence according to a specified key selector function and compares the keys by using a specified comparer.

Namespace: System.Linq
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function GroupBy(Of TSource, TKey) ( _
    source As ParallelQuery(Of TSource), _
    keySelector As Func(Of TSource, TKey), _
    comparer As IEqualityComparer(Of TKey) _
) As ParallelQuery(Of IGrouping(Of TKey, TSource))
C#
public static ParallelQuery<IGrouping<TKey, TSource>> GroupBy<TSource, TKey>(
    ParallelQuery<TSource> source,
    Func<TSource, TKey> keySelector,
    IEqualityComparer<TKey> comparer
)

Parameters

source
Type: System.Linq..::.ParallelQuery <(Of <(TSource>)>)
An OrderedParallelQuery{TSource} than contains elements to sort.
keySelector
Type: System..::.Func<(Of <(TSource, TKey>)>)
A function to extract a key from an element.
comparer
Type: System.Collections.Generic..::.IEqualityComparer<(Of <(TKey>)>)
An IComparer{TSource} to compare keys.

Type Parameters

TSource
The type of elements of source.
TKey
The type of the key returned by keySelector>.

Return Value

An OrderedParallelQuery{TSource} whose elements are sorted descending according to a key.

Exceptions

Exception | Condition
System..::.ArgumentNullException | source or keySelector is a null reference (Nothing in Visual Basic).

See Also

ParallelEnumerable Class
GroupBy Overload
System.Linq Namespace


GroupBy(TSource, TKey, TElement) Method (ParallelQuery(TSource), Func(TSource, TKey), Func(TSource, TElement))

[image]

.NET Framework Class Library
ParallelEnumerable..::.GroupBy<(Of <(TSource, TKey, TElement>)>) Method (ParallelQuery<(Of <(TSource>)>), Func<(Of <(TSource, TKey>)>), Func<(Of <(TSource, TElement>)>))
ParallelEnumerable Class See Also Send Feedback

Groups in parallel the elements of a sequence according to a specified key selector function and projects the elements for each group by using a specified function.

Namespace: System.Linq
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function GroupBy(Of TSource, TKey, TElement) ( _
    source As ParallelQuery(Of TSource), _
    keySelector As Func(Of TSource, TKey), _
    elementSelector As Func(Of TSource, TElement) _
) As ParallelQuery(Of IGrouping(Of TKey, TElement))
C#
public static ParallelQuery<IGrouping<TKey, TElement>> GroupBy<TSource, TKey, TElement>(
    ParallelQuery<TSource> source,
    Func<TSource, TKey> keySelector,
    Func<TSource, TElement> elementSelector
)

Parameters

source
Type: System.Linq..::.ParallelQuery <(Of <(TSource>)>)
An OrderedParallelQuery<(Of <(TElement>)>) than contains elements to sort.
keySelector
Type: System..::.Func<(Of <(TSource, TKey>)>)
A function to extract a key from an element.
elementSelector
Type: System..::.Func<(Of <(TSource, TElement>)>)
A function to map each source element to an element in an IGrouping.

Type Parameters

TSource
The type of elements of source.
TKey
The type of the key returned by keySelector.
TElement
The type of the elements in the IGrouping

Return Value

A ParallelQuery<IGrouping<TKey, TElement>> in C# or ParallelQuery(Of IGrouping(Of TKey, TElement)) in Visual Basic where each IGrouping generic object contains a collection of objects of type TElement and a key.

Exceptions

Exception | Condition
System..::.ArgumentNullException | source or keySelector or elementSelector is a null reference (Nothing in Visual Basic).

See Also

ParallelEnumerable Class
GroupBy Overload
System.Linq Namespace


GroupBy(TSource, TKey, TResult) Method (ParallelQuery(TSource), Func(TSource, TKey), Func(TKey, IEnumerable(TSource), TResult))

[image]

.NET Framework Class Library
ParallelEnumerable..::.GroupBy<(Of <(TSource, TKey, TResult>)>) Method (ParallelQuery<(Of <(TSource>)>), Func<(Of <(TSource, TKey>)>), Func<(Of <(TKey, IEnumerable<(Of <(TSource>)>), TResult>)>))
ParallelEnumerable Class See Also Send Feedback

Groups in parallel the elements of a sequence according to a specified key selector function and creates a result value from each group and its key.

Namespace: System.Linq
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function GroupBy(Of TSource, TKey, TResult) ( _
    source As ParallelQuery(Of TSource), _
    keySelector As Func(Of TSource, TKey), _
    resultSelector As Func(Of TKey, IEnumerable(Of TSource), TResult) _
) As ParallelQuery(Of TResult)
C#
public static ParallelQuery<TResult> GroupBy<TSource, TKey, TResult>(
    ParallelQuery<TSource> source,
    Func<TSource, TKey> keySelector,
    Func<TKey, IEnumerable<TSource>, TResult> resultSelector
)

Parameters

source
Type: System.Linq..::.ParallelQuery <(Of <(TSource>)>)
A sequence whose elements to group.
keySelector
Type: System..::.Func<(Of <(TSource, TKey>)>)
A function to extract the key for each element.
resultSelector
Type: System..::.Func<(Of <(TKey, IEnumerable<(Of <(TSource>)>), TResult>)>)
A function to create a result value from each group.

Type Parameters

TSource
The type of the elements of source.
TKey
The type of the key returned by keySelector.
TResult
The type of the result value returned by resultSelector.

Return Value

A collection of elements of type TResult where each element represents a projection over a group and its key.

Exceptions

Exception | Condition
System..::.ArgumentNullException | source or keySelector or resultSelector is a null reference (Nothing in Visual Basic).

See Also

ParallelEnumerable Class
GroupBy Overload
System.Linq Namespace


GroupBy(TSource, TKey, TElement) Method (ParallelQuery(TSource), Func(TSource, TKey), Func(TSource, TElement), IEqualityComparer(TKey))

[image]

.NET Framework Class Library
ParallelEnumerable..::.GroupBy<(Of <(TSource, TKey, TElement>)>) Method (ParallelQuery<(Of <(TSource>)>), Func<(Of <(TSource, TKey>)>), Func<(Of <(TSource, TElement>)>), IEqualityComparer<(Of <(TKey>)>))
ParallelEnumerable Class See Also Send Feedback

Groups in parallel 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.

Namespace: System.Linq
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function GroupBy(Of TSource, TKey, TElement) ( _
    source As ParallelQuery(Of TSource), _
    keySelector As Func(Of TSource, TKey), _
    elementSelector As Func(Of TSource, TElement), _
    comparer As IEqualityComparer(Of TKey) _
) As ParallelQuery(Of IGrouping(Of TKey, TElement))
C#
public static ParallelQuery<IGrouping<TKey, TElement>> GroupBy<TSource, TKey, TElement>(
    ParallelQuery<TSource> source,
    Func<TSource, TKey> keySelector,
    Func<TSource, TElement> elementSelector,
    IEqualityComparer<TKey> comparer
)

Parameters

source
Type: System.Linq..::.ParallelQuery <(Of <(TSource>)>)
An OrderedParallelQuery{TSource}than contains elements to sort.
keySelector
Type: System..::.Func<(Of <(TSource, TKey>)>)
A function to extract a key from an element.
elementSelector
Type: System..::.Func<(Of <(TSource, TElement>)>)
A function to map each source element to an element in an IGrouping.
comparer
Type: System.Collections.Generic..::.IEqualityComparer<(Of <(TKey>)>)
An IComparer{TSource} to compare keys.

Type Parameters

TSource
The type of elements of source.
TKey
The type of the key returned by keySelector.
TElement
The type of the elements in the IGrouping

Return Value

A ParallelQuery{IGrouping{TKey, TElement}} in C# or ParallelQuery(Of IGrouping(Of TKey, TElement)) in Visual Basic where each IGrouping generic object contains a collection of objects of type TElement and a key.

Exceptions

Exception | Condition
System..::.ArgumentNullException | source or keySelector or elementSelector is a null reference (Nothing in Visual Basic).

See Also

ParallelEnumerable Class
GroupBy Overload
System.Linq Namespace


GroupBy(TSource, TKey, TElement, TResult) Method (ParallelQuery(TSource), Func(TSource, TKey), Func(TSource, TElement), Func(TKey, IEnumerable(TElement), TResult))

[image]

.NET Framework Class Library
ParallelEnumerable..::.GroupBy<(Of <(TSource, TKey, TElement, TResult>)>) Method (ParallelQuery<(Of <(TSource>)>), Func<(Of <(TSource, TKey>)>), Func<(Of <(TSource, TElement>)>), Func<(Of <(TKey, IEnumerable<(Of <(TElement>)>), TResult>)>))
ParallelEnumerable Class See Also Send Feedback

Groups in parallel 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.

Namespace: System.Linq
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function GroupBy(Of TSource, TKey, TElement, TResult) ( _
    source As ParallelQuery(Of TSource), _
    keySelector As Func(Of TSource, TKey), _
    elementSelector As Func(Of TSource, TElement), _
    resultSelector As Func(Of TKey, IEnumerable(Of TElement), TResult) _
) As ParallelQuery(Of TResult)
C#
public static ParallelQuery<TResult> GroupBy<TSource, TKey, TElement, TResult>(
    ParallelQuery<TSource> source,
    Func<TSource, TKey> keySelector,
    Func<TSource, TElement> elementSelector,
    Func<TKey, IEnumerable<TElement>, TResult> resultSelector
)

Parameters

source
Type: System.Linq..::.ParallelQuery <(Of <(TSource>)>)
A sequence whose elements to group.
keySelector
Type: System..::.Func<(Of <(TSource, TKey>)>)
A function to extract the key for each element.
elementSelector
Type: System..::.Func<(Of <(TSource, TElement>)>)
A function to map each source element to an element in an IGrouping<TKey, TElement>.
resultSelector
Type: System..::.Func<(Of <(TKey, IEnumerable<(Of <(TElement>)>), TResult>)>)
A function to create a result value from each group.

Type Parameters

TSource
The type of the elements of source.
TKey
The type of the key returned by keySelector.
TElement
The type of the elements in each IGrouping{TKey, TElement}.
TResult
The type of the result value returned by resultSelector.

Return Value

A collection of elements of type TElement where each element represents a projection over a group and its key.

Exceptions

Exception | Condition
System..::.ArgumentNullException | source or keySelector or elementSelector or resultSelector is a null reference (Nothing in Visual Basic).

See Also

ParallelEnumerable Class
GroupBy Overload
System.Linq Namespace


GroupBy(TSource, TKey, TResult) Method (ParallelQuery(TSource), Func(TSource, TKey), Func(TKey, IEnumerable(TSource), TResult), IEqualityComparer(TKey))

[image]

.NET Framework Class Library
ParallelEnumerable..::.GroupBy<(Of <(TSource, TKey, TResult>)>) Method (ParallelQuery<(Of <(TSource>)>), Func<(Of <(TSource, TKey>)>), Func<(Of <(TKey, IEnumerable<(Of <(TSource>)>), TResult>)>), IEqualityComparer<(Of <(TKey>)>))
ParallelEnumerable Class See Also Send Feedback

Groups in parallel 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.

Namespace: System.Linq
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function GroupBy(Of TSource, TKey, TResult) ( _
    source As ParallelQuery(Of TSource), _
    keySelector As Func(Of TSource, TKey), _
    resultSelector As Func(Of TKey, IEnumerable(Of TSource), TResult), _
    comparer As IEqualityComparer(Of TKey) _
) As ParallelQuery(Of TResult)
C#
public static ParallelQuery<TResult> GroupBy<TSource, TKey, TResult>(
    ParallelQuery<TSource> source,
    Func<TSource, TKey> keySelector,
    Func<TKey, IEnumerable<TSource>, TResult> resultSelector,
    IEqualityComparer<TKey> comparer
)

Parameters

source
Type: System.Linq..::.ParallelQuery <(Of <(TSource>)>)
A sequence whose elements to group.
keySelector
Type: System..::.Func<(Of <(TSource, TKey>)>)
A function to extract the key for each element.
resultSelector
Type: System..::.Func<(Of <(TKey, IEnumerable<(Of <(TSource>)>), TResult>)>)
A function to create a result value from each group.
comparer
Type: System.Collections.Generic..::.IEqualityComparer<(Of <(TKey>)>)
An IEqualityComparer{TKey} to compare keys.

Type Parameters

TSource
The type of the elements of source.
TKey
The type of the key returned by keySelector.
TResult
The type of the result value returned by resultSelector.

Return Value

An ParallelQuery<IGrouping<TKey, TResult>> in C# or ParallelQuery(Of IGrouping(Of TKey, TResult)) in Visual Basic where each IGrouping<(Of <(TKey, TResult>)>) object contains a collection of objects of type TResult and a key.

Exceptions

Exception | Condition
System..::.ArgumentNullException | source or keySelector or resultSelector is a null reference (Nothing in Visual Basic).

See Also

ParallelEnumerable Class
GroupBy Overload
System.Linq Namespace


GroupBy(TSource, TKey, TElement, TResult) Method (ParallelQuery(TSource), Func(TSource, TKey), Func(TSource, TElement), Func(TKey, IEnumerable(TElement), TResult), IEqualityComparer(TKey))

[image]

.NET Framework Class Library
ParallelEnumerable..::.GroupBy<(Of <(TSource, TKey, TElement, TResult>)>) Method (ParallelQuery<(Of <(TSource>)>), Func<(Of <(TSource, TKey>)>), Func<(Of <(TSource, TElement>)>), Func<(Of <(TKey, IEnumerable<(Of <(TElement>)>), TResult>)>), IEqualityComparer<(Of <(TKey>)>))
ParallelEnumerable Class See Also Send Feedback

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.

Namespace: System.Linq
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function GroupBy(Of TSource, TKey, TElement, TResult) ( _
    source As ParallelQuery(Of TSource), _
    keySelector As Func(Of TSource, TKey), _
    elementSelector As Func(Of TSource, TElement), _
    resultSelector As Func(Of TKey, IEnumerable(Of TElement), TResult), _
    comparer As IEqualityComparer(Of TKey) _
) As ParallelQuery(Of TResult)
C#
public static ParallelQuery<TResult> GroupBy<TSource, TKey, TElement, TResult>(
    ParallelQuery<TSource> source,
    Func<TSource, TKey> keySelector,
    Func<TSource, TElement> elementSelector,
    Func<TKey, IEnumerable<TElement>, TResult> resultSelector,
    IEqualityComparer<TKey> comparer
)

Parameters

source
Type: System.Linq..::.ParallelQuery <(Of <(TSource>)>)
A sequence whose elements to group.
keySelector
Type: System..::.Func<(Of <(TSource, TKey>)>)
A function to extract the key for each element.
elementSelector
Type: System..::.Func<(Of <(TSource, TElement>)>)
A function to map each source element to an element in an IGrouping{Key, TElement}.
resultSelector
Type: System..::.Func<(Of <(TKey, IEnumerable<(Of <(TElement>)>), TResult>)>)
A function to create a result value from each group.
comparer
Type: System.Collections.Generic..::.IEqualityComparer<(Of <(TKey>)>)
An IEqualityComparer{TKey} to compare keys.

Type Parameters

TSource
The type of the elements of source.
TKey
The type of the key returned by keySelector.
TElement
The type of the elements in each IGrouping{TKey, TElement}.
TResult
The type of the result value returned by resultSelector.

Return Value

A collection of elements of type TResult where each element represents a projection over a group and its key.

Exceptions

Exception | Condition
System..::.ArgumentNullException | source or keySelector or elementSelector or resultSelector is a null reference (Nothing in Visual Basic).

See Also

ParallelEnumerable Class
GroupBy Overload
System.Linq Namespace


GroupJoin Method

[image] [image]

.NET Framework Class Library
ParallelEnumerable..::.GroupJoin Method
ParallelEnumerable Class See Also Send Feedback

Overload List

Name | Description
GroupJoin<(Of <(TOuter, TInner, TKey, TResult>)>)(ParallelQuery<(Of <(TOuter>)>), IEnumerable<(Of <(TInner>)>), Func<(Of <(TOuter, TKey>)>), Func<(Of <(TInner, TKey>)>), Func<(Of <(TOuter, IEnumerable<(Of <(TInner>)>), TResult>)>)) | Obsolete. This GroupJoin overload should never be called. This method is marked as obsolete and always throws NotSupportedException when called.
GroupJoin<(Of <(TOuter, TInner, TKey, TResult>)>)(ParallelQuery<(Of <(TOuter>)>), ParallelQuery<(Of <(TInner>)>), Func<(Of <(TOuter, TKey>)>), Func<(Of <(TInner, TKey>)>), Func<(Of <(TOuter, IEnumerable<(Of <(TInner>)>), TResult>)>)) | Correlates in parallel the elements of two sequences based on equality of keys and groups the results. The default equality comparer is used to compare keys.
GroupJoin<(Of <(TOuter, TInner, TKey, TResult>)>)(ParallelQuery<(Of <(TOuter>)>), IEnumerable<(Of <(TInner>)>), Func<(Of <(TOuter, TKey>)>), Func<(Of <(TInner, TKey>)>), Func<(Of <(TOuter, IEnumerable<(Of <(TInner>)>), TResult>)>), IEqualityComparer<(Of <(TKey>)>)) | Obsolete. This GroupJoin overload should never be called. This method is marked as obsolete and always throws NotSupportedException when called.
GroupJoin<(Of <(TOuter, TInner, TKey, TResult>)>)(ParallelQuery<(Of <(TOuter>)>), ParallelQuery<(Of <(TInner>)>), Func<(Of <(TOuter, TKey>)>), Func<(Of <(TInner, TKey>)>), Func<(Of <(TOuter, IEnumerable<(Of <(TInner>)>), TResult>)>), IEqualityComparer<(Of <(TKey>)>)) | Correlates in parallel the elements of two sequences based on key equality and groups the results. A specified IEqualityComparer{T} is used to compare keys.

See Also

ParallelEnumerable Class
System.Linq Namespace


GroupJoin(TOuter, TInner, TKey, TResult) Method (ParallelQuery(TOuter), IEnumerable(TInner), Func(TOuter, TKey), Func(TInner, TKey), Func(TOuter, IEnumerable(TInner), TResult))

[image]

.NET Framework Class Library
ParallelEnumerable..::.GroupJoin<(Of <(TOuter, TInner, TKey, TResult>)>) Method (ParallelQuery<(Of <(TOuter>)>), IEnumerable<(Of <(TInner>)>), Func<(Of <(TOuter, TKey>)>), Func<(Of <(TInner, TKey>)>), Func<(Of <(TOuter, IEnumerable<(Of <(TInner>)>), TResult>)>))
ParallelEnumerable Class See Also Send Feedback

This GroupJoin overload should never be called. This method is marked as obsolete and always throws NotSupportedException when called.

Namespace: System.Linq
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
<ObsoleteAttribute("The second data source of a binary operator must be of type System.Linq.ParallelQuery<T> rather than System.Collections.Generic.IEnumerable<T>. To fix this problem, use the AsParallel() extension method to convert the right data source to System.Linq.ParallelQuery<T>.")> _
Public Shared Function GroupJoin(Of TOuter, TInner, TKey, TResult) ( _
    outer As ParallelQuery(Of TOuter), _
    inner As IEnumerable(Of TInner), _
    outerKeySelector As Func(Of TOuter, TKey), _
    innerKeySelector As Func(Of TInner, TKey), _
    resultSelector As Func(Of TOuter, IEnumerable(Of TInner), TResult) _
) As ParallelQuery(Of TResult)
C#
[ObsoleteAttribute("The second data source of a binary operator must be of type System.Linq.ParallelQuery<T> rather than System.Collections.Generic.IEnumerable<T>. To fix this problem, use the AsParallel() extension method to convert the right data source to System.Linq.ParallelQuery<T>.")]
public static ParallelQuery<TResult> GroupJoin<TOuter, TInner, TKey, TResult>(
    ParallelQuery<TOuter> outer,
    IEnumerable<TInner> inner,
    Func<TOuter, TKey> outerKeySelector,
    Func<TInner, TKey> innerKeySelector,
    Func<TOuter, IEnumerable<TInner>, TResult> resultSelector
)

Parameters

outer
Type: System.Linq..::.ParallelQuery <(Of <(TOuter>)>)
This parameter is not used.
inner
Type: System.Collections.Generic..::.IEnumerable<(Of <(TInner>)>)
This parameter is not used.
outerKeySelector
Type: System..::.Func<(Of <(TOuter, TKey>)>)
This parameter is not used.
innerKeySelector
Type: System..::.Func<(Of <(TInner, TKey>)>)
This parameter is not used.
resultSelector
Type: System..::.Func<(Of <(TOuter, IEnumerable<(Of <(TInner>)>), TResult>)>)
This parameter is not used.

Type Parameters

TOuter
This type parameter is not used.
TInner
This type parameter is not used.
TKey
This type parameter is not used.
TResult
This type parameter is not used.

Return Value

This overload always throws a NotSupportedException.

Remarks

This overload exists to disallow usage of GroupJoin with a left data source of type ParallelQuery<(Of <(TSource>)>) and a right data source of type IEnumerable<(Of <(T>)>). Otherwise, the GroupJoin operator would appear to be binding to the parallel implementation, but would in reality bind to the sequential implementation.

Exceptions

Exception | Condition
System..::.NotSupportedException | The exception that occurs when this method is called.

See Also

ParallelEnumerable Class
GroupJoin Overload
System.Linq Namespace


GroupJoin(TOuter, TInner, TKey, TResult) Method (ParallelQuery(TOuter), ParallelQuery(TInner), Func(TOuter, TKey), Func(TInner, TKey), Func(TOuter, IEnumerable(TInner), TResult))

[image]

.NET Framework Class Library
ParallelEnumerable..::.GroupJoin<(Of <(TOuter, TInner, TKey, TResult>)>) Method (ParallelQuery<(Of <(TOuter>)>), ParallelQuery<(Of <(TInner>)>), Func<(Of <(TOuter, TKey>)>), Func<(Of <(TInner, TKey>)>), Func<(Of <(TOuter, IEnumerable<(Of <(TInner>)>), TResult>)>))
ParallelEnumerable Class See Also Send Feedback

Correlates in parallel the elements of two sequences based on equality of keys and groups the results. The default equality comparer is used to compare keys.

Namespace: System.Linq
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function GroupJoin(Of TOuter, TInner, TKey, TResult) ( _
    outer As ParallelQuery(Of TOuter), _
    inner As ParallelQuery(Of TInner), _
    outerKeySelector As Func(Of TOuter, TKey), _
    innerKeySelector As Func(Of TInner, TKey), _
    resultSelector As Func(Of TOuter, IEnumerable(Of TInner), TResult) _
) As ParallelQuery(Of TResult)
C#
public static ParallelQuery<TResult> GroupJoin<TOuter, TInner, TKey, TResult>(
    ParallelQuery<TOuter> outer,
    ParallelQuery<TInner> inner,
    Func<TOuter, TKey> outerKeySelector,
    Func<TInner, TKey> innerKeySelector,
    Func<TOuter, IEnumerable<TInner>, TResult> resultSelector
)

Parameters

outer
Type: System.Linq..::.ParallelQuery <(Of <(TOuter>)>)
The first sequence to join.
inner
Type: System.Linq..::.ParallelQuery <(Of <(TInner>)>)
The sequence to join to the first sequence.
outerKeySelector
Type: System..::.Func<(Of <(TOuter, TKey>)>)
A function to extract the join key from each element of the first sequence.
innerKeySelector
Type: System..::.Func<(Of <(TInner, TKey>)>)
A function to extract the join key from each element of the second sequence.
resultSelector
Type: System..::.Func<(Of <(TOuter, IEnumerable<(Of <(TInner>)>), TResult>)>)
A function to create a result element from an element from the first sequence and a collection of matching elements from the second sequence.

Type Parameters

TOuter
The type of the elements of the first sequence.
TInner
The type of the elements of the second sequence.
TKey
The type of the keys returned by the key selector functions.
TResult
The type of the result elements.

Return Value

A sequence that has elements of type TResult that are obtained by performing a grouped join on two sequences.

Exceptions

Exception | Condition
System..::.ArgumentNullException | outer or inner or outerKeySelector or innerKeySelector or resultSelector is a null reference (Nothing in Visual Basic).

See Also

ParallelEnumerable Class
GroupJoin Overload
System.Linq Namespace


GroupJoin(TOuter, TInner, TKey, TResult) Method (ParallelQuery(TOuter), IEnumerable(TInner), Func(TOuter, TKey), Func(TInner, TKey), Func(TOuter, IEnumerable(TInner), TResult), IEqualityComparer(TKey))

[image]

.NET Framework Class Library
ParallelEnumerable..::.GroupJoin<(Of <(TOuter, TInner, TKey, TResult>)>) Method (ParallelQuery<(Of <(TOuter>)>), IEnumerable<(Of <(TInner>)>), Func<(Of <(TOuter, TKey>)>), Func<(Of <(TInner, TKey>)>), Func<(Of <(TOuter, IEnumerable<(Of <(TInner>)>), TResult>)>), IEqualityComparer<(Of <(TKey>)>))
ParallelEnumerable Class See Also Send Feedback

This GroupJoin overload should never be called. This method is marked as obsolete and always throws NotSupportedException when called.

Namespace: System.Linq
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
<ObsoleteAttribute("The second data source of a binary operator must be of type System.Linq.ParallelQuery<T> rather than System.Collections.Generic.IEnumerable<T>. To fix this problem, use the AsParallel() extension method to convert the right data source to System.Linq.ParallelQuery<T>.")> _
Public Shared Function GroupJoin(Of TOuter, TInner, TKey, TResult) ( _
    outer As ParallelQuery(Of TOuter), _
    inner As IEnumerable(Of TInner), _
    outerKeySelector As Func(Of TOuter, TKey), _
    innerKeySelector As Func(Of TInner, TKey), _
    resultSelector As Func(Of TOuter, IEnumerable(Of TInner), TResult), _
    comparer As IEqualityComparer(Of TKey) _
) As ParallelQuery(Of TResult)
C#
[ObsoleteAttribute("The second data source of a binary operator must be of type System.Linq.ParallelQuery<T> rather than System.Collections.Generic.IEnumerable<T>. To fix this problem, use the AsParallel() extension method to convert the right data source to System.Linq.ParallelQuery<T>.")]
public static ParallelQuery<TResult> GroupJoin<TOuter, TInner, TKey, TResult>(
    ParallelQuery<TOuter> outer,
    IEnumerable<TInner> inner,
    Func<TOuter, TKey> outerKeySelector,
    Func<TInner, TKey> innerKeySelector,
    Func<TOuter, IEnumerable<TInner>, TResult> resultSelector,
    IEqualityComparer<TKey> comparer
)

Parameters

outer
Type: System.Linq..::.ParallelQuery <(Of <(TOuter>)>)
This parameter is not used.
inner
Type: System.Collections.Generic..::.IEnumerable<(Of <(TInner>)>)
This parameter is not used.
outerKeySelector
Type: System..::.Func<(Of <(TOuter, TKey>)>)
This parameter is not used.
innerKeySelector
Type: System..::.Func<(Of <(TInner, TKey>)>)
This parameter is not used.
resultSelector
Type: System..::.Func<(Of <(TOuter, IEnumerable<(Of <(TInner>)>), TResult>)>)
This parameter is not used.
comparer
Type: System.Collections.Generic..::.IEqualityComparer<(Of <(TKey>)>)
This parameter is not used.

Type Parameters

TOuter
This type parameter is not used.
TInner
This type parameter is not used.
TKey
This type parameter is not used.
TResult
This type parameter is not used.

Return Value

This overload always throws a NotSupportedException.

Remarks

This overload exists to disallow usage of GroupJoin with a left data source of type ParallelQuery<(Of <(TSource>)>) and a right data source of type IEnumerable<(Of <(T>)>). Otherwise, the GroupJoin operator would appear to be binding to the parallel implementation, but would in reality bind to the sequential implementation.

Exceptions

Exception | Condition
System..::.NotSupportedException | The exception that occurs when this method is called.

See Also

ParallelEnumerable Class
GroupJoin Overload
System.Linq Namespace


GroupJoin(TOuter, TInner, TKey, TResult) Method (ParallelQuery(TOuter), ParallelQuery(TInner), Func(TOuter, TKey), Func(TInner, TKey), Func(TOuter, IEnumerable(TInner), TResult), IEqualityComparer(TKey))

[image]

.NET Framework Class Library
ParallelEnumerable..::.GroupJoin<(Of <(TOuter, TInner, TKey, TResult>)>) Method (ParallelQuery<(Of <(TOuter>)>), ParallelQuery<(Of <(TInner>)>), Func<(Of <(TOuter, TKey>)>), Func<(Of <(TInner, TKey>)>), Func<(Of <(TOuter, IEnumerable<(Of <(TInner>)>), TResult>)>), IEqualityComparer<(Of <(TKey>)>))
ParallelEnumerable Class See Also Send Feedback

Correlates in parallel the elements of two sequences based on key equality and groups the results. A specified IEqualityComparer{T} is used to compare keys.

Namespace: System.Linq
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function GroupJoin(Of TOuter, TInner, TKey, TResult) ( _
    outer As ParallelQuery(Of TOuter), _
    inner As ParallelQuery(Of TInner), _
    outerKeySelector As Func(Of TOuter, TKey), _
    innerKeySelector As Func(Of TInner, TKey), _
    resultSelector As Func(Of TOuter, IEnumerable(Of TInner), TResult), _
    comparer As IEqualityComparer(Of TKey) _
) As ParallelQuery(Of TResult)
C#
public static ParallelQuery<TResult> GroupJoin<TOuter, TInner, TKey, TResult>(
    ParallelQuery<TOuter> outer,
    ParallelQuery<TInner> inner,
    Func<TOuter, TKey> outerKeySelector,
    Func<TInner, TKey> innerKeySelector,
    Func<TOuter, IEnumerable<TInner>, TResult> resultSelector,
    IEqualityComparer<TKey> comparer
)

Parameters

outer
Type: System.Linq..::.ParallelQuery <(Of <(TOuter>)>)
The first sequence to join.
inner
Type: System.Linq..::.ParallelQuery <(Of <(TInner>)>)
The sequence to join to the first sequence.
outerKeySelector
Type: System..::.Func<(Of <(TOuter, TKey>)>)
A function to extract the join key from each element of the first sequence.
innerKeySelector
Type: System..::.Func<(Of <(TInner, TKey>)>)
A function to extract the join key from each element of the second sequence.
resultSelector
Type: System..::.Func<(Of <(TOuter, IEnumerable<(Of <(TInner>)>), TResult>)>)
A function to create a result element from an element from the first sequence and a collection of matching elements from the second sequence.
comparer
Type: System.Collections.Generic..::.IEqualityComparer<(Of <(TKey>)>)
An IEqualityComparer<(Of <(T>)>) to hash and compare keys.

Type Parameters

TOuter
The type of the elements of the first sequence.
TInner
The type of the elements of the second sequence.
TKey
The type of the keys returned by the key selector functions.
TResult
The type of the result elements.

Return Value

A sequence that has elements of type TResult that are obtained by performing a grouped join on two sequences.

Exceptions

Exception | Condition
System..::.ArgumentNullException | outer or inner or outerKeySelector or innerKeySelector or resultSelector is a null reference (Nothing in Visual Basic).

See Also

ParallelEnumerable Class
GroupJoin Overload
System.Linq Namespace


Intersect Method

[image] [image]

.NET Framework Class Library
ParallelEnumerable..::.Intersect Method
ParallelEnumerable Class See Also Send Feedback

Overload List

Name | Description
Intersect<(Of <(TSource>)>)(ParallelQuery<(Of <(TSource>)>), IEnumerable<(Of <(TSource>)>)) | Obsolete. This Intersect overload should never be called. This method is marked as obsolete and always throws NotSupportedException when called.
Intersect<(Of <(TSource>)>)(ParallelQuery<(Of <(TSource>)>), ParallelQuery<(Of <(TSource>)>)) | Produces the set intersection of two parallel sequences by using the default equality comparer to compare values.
Intersect<(Of <(TSource>)>)(ParallelQuery<(Of <(TSource>)>), IEnumerable<(Of <(TSource>)>), IEqualityComparer<(Of <(TSource>)>)) | Obsolete. This Intersect overload should never be called. This method is marked as obsolete and always throws NotSupportedException when called.
Intersect<(Of <(TSource>)>)(ParallelQuery<(Of <(TSource>)>), ParallelQuery<(Of <(TSource>)>), IEqualityComparer<(Of <(TSource>)>)) | Produces the set intersection of two parallel sequences by using the specified IEqualityComparer{T} to compare values.

See Also

ParallelEnumerable Class
System.Linq Namespace


Intersect(TSource) Method (ParallelQuery(TSource), IEnumerable(TSource))

[image]

.NET Framework Class Library
ParallelEnumerable..::.Intersect<(Of <(TSource>)>) Method (ParallelQuery<(Of <(TSource>)>), IEnumerable<(Of <(TSource>)>))
ParallelEnumerable Class See Also Send Feedback

This Intersect overload should never be called. This method is marked as obsolete and always throws NotSupportedException when called.

Namespace: System.Linq
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
<ObsoleteAttribute("The second data source of a binary operator must be of type System.Linq.ParallelQuery<T> rather than System.Collections.Generic.IEnumerable<T>. To fix this problem, use the AsParallel() extension method to convert the right data source to System.Linq.ParallelQuery<T>.")> _
Public Shared Function Intersect(Of TSource) ( _
    first As ParallelQuery(Of TSource), _
    second As IEnumerable(Of TSource) _
) As ParallelQuery(Of TSource)
C#
[ObsoleteAttribute("The second data source of a binary operator must be of type System.Linq.ParallelQuery<T> rather than System.Collections.Generic.IEnumerable<T>. To fix this problem, use the AsParallel() extension method to convert the right data source to System.Linq.ParallelQuery<T>.")]
public static ParallelQuery<TSource> Intersect<TSource>(
    ParallelQuery<TSource> first,
    IEnumerable<TSource> second
)

Parameters

first
Type: System.Linq..::.ParallelQuery <(Of <(TSource>)>)
This parameter is not used.
second
Type: System.Collections.Generic..::.IEnumerable<(Of <(TSource>)>)
This parameter is not used.

Type Parameters

TSource
This type parameter is not used.

Return Value

This overload always throws a NotSupportedException.

Remarks

This overload exists to disallow usage of Intersect with a left data source of type ParallelQuery<(Of <(TSource>)>) and a right data source of type IEnumerable<(Of <(T>)>). Otherwise, the Intersect operator would appear to be binding to the parallel implementation, but would in reality bind to the sequential implementation.

Exceptions

Exception | Condition
System..::.NotSupportedException | The exception that occurs when this method is called.

See Also

ParallelEnumerable Class
Intersect Overload
System.Linq Namespace


Intersect(TSource) Method (ParallelQuery(TSource), ParallelQuery(TSource))

[image]

.NET Framework Class Library
ParallelEnumerable..::.Intersect<(Of <(TSource>)>) Method (ParallelQuery<(Of <(TSource>)>), ParallelQuery<(Of <(TSource>)>))
ParallelEnumerable Class See Also Send Feedback

Produces the set intersection of two parallel sequences by using the default equality comparer to compare values.

Namespace: System.Linq
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function Intersect(Of TSource) ( _
    first As ParallelQuery(Of TSource), _
    second As ParallelQuery(Of TSource) _
) As ParallelQuery(Of TSource)
C#
public static ParallelQuery<TSource> Intersect<TSource>(
    ParallelQuery<TSource> first,
    ParallelQuery<TSource> second
)

Parameters

first
Type: System.Linq..::.ParallelQuery <(Of <(TSource>)>)
A sequence whose distinct elements that also appear in second will be returned.
second
Type: System.Linq..::.ParallelQuery <(Of <(TSource>)>)
A sequence whose distinct elements that also appear in the first sequence will be returned.

Type Parameters

TSource
The type of the elements of the input sequences.

Return Value

A sequence that contains the elements that form the set intersection of two sequences.

Exceptions

Exception | Condition
System..::.ArgumentNullException | first or second is a null reference (Nothing in Visual Basic).

See Also

ParallelEnumerable Class
Intersect Overload
System.Linq Namespace


Intersect(TSource) Method (ParallelQuery(TSource), IEnumerable(TSource), IEqualityComparer(TSource))

[image]

.NET Framework Class Library
ParallelEnumerable..::.Intersect<(Of <(TSource>)>) Method (ParallelQuery<(Of <(TSource>)>), IEnumerable<(Of <(TSource>)>), IEqualityComparer<(Of <(TSource>)>))
ParallelEnumerable Class See Also Send Feedback

This Intersect overload should never be called. This method is marked as obsolete and always throws NotSupportedException when called.

Namespace: System.Linq
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
<ObsoleteAttribute("The second data source of a binary operator must be of type System.Linq.ParallelQuery<T> rather than System.Collections.Generic.IEnumerable<T>. To fix this problem, use the AsParallel() extension method to convert the right data source to System.Linq.ParallelQuery<T>.")> _
Public Shared Function Intersect(Of TSource) ( _
    first As ParallelQuery(Of TSource), _
    second As IEnumerable(Of TSource), _
    comparer As IEqualityComparer(Of TSource) _
) As ParallelQuery(Of TSource)
C#
[ObsoleteAttribute("The second data source of a binary operator must be of type System.Linq.ParallelQuery<T> rather than System.Collections.Generic.IEnumerable<T>. To fix this problem, use the AsParallel() extension method to convert the right data source to System.Linq.ParallelQuery<T>.")]
public static ParallelQuery<TSource> Intersect<TSource>(
    ParallelQuery<TSource> first,
    IEnumerable<TSource> second,
    IEqualityComparer<TSource> comparer
)

Parameters

first
Type: System.Linq..::.ParallelQuery <(Of <(TSource>)>)
This parameter is not used.
second
Type: System.Collections.Generic..::.IEnumerable<(Of <(TSource>)>)
This parameter is not used.
comparer
Type: System.Collections.Generic..::.IEqualityComparer<(Of <(TSource>)>)
This parameter is not used.

Type Parameters

TSource
This type parameter is not used.

Return Value

This overload always throws a NotSupportedException.

Remarks

This overload exists to disallow usage of Intersect with a left data source of type ParallelQuery<(Of <(TSource>)>) and a right data source of type IEnumerable<(Of <(T>)>). Otherwise, the Intersect operator would appear to be binding to the parallel implementation, but would in reality bind to the sequential implementation.

Exceptions

Exception | Condition
System..::.NotSupportedException | The exception that occurs when this method is called.

See Also

ParallelEnumerable Class
Intersect Overload
System.Linq Namespace


Intersect(TSource) Method (ParallelQuery(TSource), ParallelQuery(TSource), IEqualityComparer(TSource))

[image]

.NET Framework Class Library
ParallelEnumerable..::.Intersect<(Of <(TSource>)>) Method (ParallelQuery<(Of <(TSource>)>), ParallelQuery<(Of <(TSource>)>), IEqualityComparer<(Of <(TSource>)>))
ParallelEnumerable Class See Also Send Feedback

Produces the set intersection of two parallel sequences by using the specified IEqualityComparer{T} to compare values.

Namespace: System.Linq
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function Intersect(Of TSource) ( _
    first As ParallelQuery(Of TSource), _
    second As ParallelQuery(Of TSource), _
    comparer As IEqualityComparer(Of TSource) _
) As ParallelQuery(Of TSource)
C#
public static ParallelQuery<TSource> Intersect<TSource>(
    ParallelQuery<TSource> first,
    ParallelQuery<TSource> second,
    IEqualityComparer<TSource> comparer
)

Parameters

first
Type: System.Linq..::.ParallelQuery <(Of <(TSource>)>)
A sequence whose distinct elements that also appear in second will be returned.
second
Type: System.Linq..::.ParallelQuery <(Of <(TSource>)>)
A sequence whose distinct elements that also appear in the first sequence will be returned.
comparer
Type: System.Collections.Generic..::.IEqualityComparer<(Of <(TSource>)>)
An IEqualityComparer<(Of <(T>)>) to compare values.

Type Parameters

TSource
The type of the elements of the input sequences.

Return Value

A sequence that contains the elements that form the set intersection of two sequences.

Exceptions

Exception | Condition
System..::.ArgumentNullException | first or second is a null reference (Nothing in Visual Basic).

See Also

ParallelEnumerable Class
Intersect Overload
System.Linq Namespace


Join Method

[image] [image]

.NET Framework Class Library
ParallelEnumerable..::.Join Method
ParallelEnumerable Class See Also Send Feedback

Overload List

Name | Description
Join<(Of <(TOuter, TInner, TKey, TResult>)>)(ParallelQuery<(Of <(TOuter>)>), IEnumerable<(Of <(TInner>)>), Func<(Of <(TOuter, TKey>)>), Func<(Of <(TInner, TKey>)>), Func<(Of <(TOuter, TInner, TResult>)>)) | Obsolete. This Join overload should never be called. This method is marked as obsolete and always throws NotSupportedException when invoked.
Join<(Of <(TOuter, TInner, TKey, TResult>)>)(ParallelQuery<(Of <(TOuter>)>), ParallelQuery<(Of <(TInner>)>), Func<(Of <(TOuter, TKey>)>), Func<(Of <(TInner, TKey>)>), Func<(Of <(TOuter, TInner, TResult>)>)) | Correlates in parallel the elements of two sequences based on matching keys. The default equality comparer is used to compare keys.
Join<(Of <(TOuter, TInner, TKey, TResult>)>)(ParallelQuery<(Of <(TOuter>)>), IEnumerable<(Of <(TInner>)>), Func<(Of <(TOuter, TKey>)>), Func<(Of <(TInner, TKey>)>), Func<(Of <(TOuter, TInner, TResult>)>), IEqualityComparer<(Of <(TKey>)>)) | Obsolete. This Join overload should never be called. This method is marked as obsolete and always throws NotSupportedException when invoked.
Join<(Of <(TOuter, TInner, TKey, TResult>)>)(ParallelQuery<(Of <(TOuter>)>), ParallelQuery<(Of <(TInner>)>), Func<(Of <(TOuter, TKey>)>), Func<(Of <(TInner, TKey>)>), Func<(Of <(TOuter, TInner, TResult>)>), IEqualityComparer<(Of <(TKey>)>)) | Correlates in parallel the elements of two sequences based on matching keys. A specified IEqualityComparer{T} is used to compare keys.

See Also

ParallelEnumerable Class
System.Linq Namespace


Join(TOuter, TInner, TKey, TResult) Method (ParallelQuery(TOuter), IEnumerable(TInner), Func(TOuter, TKey), Func(TInner, TKey), Func(TOuter, TInner, TResult))

[image]

.NET Framework Class Library
ParallelEnumerable..::.Join<(Of <(TOuter, TInner, TKey, TResult>)>) Method (ParallelQuery<(Of <(TOuter>)>), IEnumerable<(Of <(TInner>)>), Func<(Of <(TOuter, TKey>)>), Func<(Of <(TInner, TKey>)>), Func<(Of <(TOuter, TInner, TResult>)>))
ParallelEnumerable Class See Also Send Feedback

This Join overload should never be called. This method is marked as obsolete and always throws NotSupportedException when invoked.

Namespace: System.Linq
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
<ObsoleteAttribute("The second data source of a binary operator must be of type System.Linq.ParallelQuery<T> rather than System.Collections.Generic.IEnumerable<T>. To fix this problem, use the AsParallel() extension method to convert the right data source to System.Linq.ParallelQuery<T>.")> _
Public Shared Function Join(Of TOuter, TInner, TKey, TResult) ( _
    outer As ParallelQuery(Of TOuter), _
    inner As IEnumerable(Of TInner), _
    outerKeySelector As Func(Of TOuter, TKey), _
    innerKeySelector As Func(Of TInner, TKey), _
    resultSelector As Func(Of TOuter, TInner, TResult) _
) As ParallelQuery(Of TResult)
C#
[ObsoleteAttribute("The second data source of a binary operator must be of type System.Linq.ParallelQuery<T> rather than System.Collections.Generic.IEnumerable<T>. To fix this problem, use the AsParallel() extension method to convert the right data source to System.Linq.ParallelQuery<T>.")]
public static ParallelQuery<TResult> Join<TOuter, TInner, TKey, TResult>(
    ParallelQuery<TOuter> outer,
    IEnumerable<TInner> inner,
    Func<TOuter, TKey> outerKeySelector,
    Func<TInner, TKey> innerKeySelector,
    Func<TOuter, TInner, TResult> resultSelector
)

Parameters

outer
Type: System.Linq..::.ParallelQuery <(Of <(TOuter>)>)
This parameter is not used.
inner
Type: System.Collections.Generic..::.IEnumerable<(Of <(TInner>)>)
This parameter is not used.
outerKeySelector
Type: System..::.Func<(Of <(TOuter, TKey>)>)
This parameter is not used.
innerKeySelector
Type: System..::.Func<(Of <(TInner, TKey>)>)
This parameter is not used.
resultSelector
Type: System..::.Func<(Of <(TOuter, TInner, TResult>)>)
This parameter is not used.

Type Parameters

TOuter
This type parameter is not used.
TInner
This type parameter is not used.
TKey
This type parameter is not used.
TResult
This type parameter is not used.

Return Value

This overload always throws a NotSupportedException.

Remarks

This overload exists to disallow usage Join with a left data source of type ParallelQuery<(Of <(TSource>)>) and a right data source of type IEnumerable<(Of <(T>)>). Otherwise, the Join operator would appear to be binding to the parallel implementation, but would in reality bind to the sequential implementation.

Exceptions

Exception | Condition
System..::.NotSupportedException | The exception that occurs when this method is called.

See Also

ParallelEnumerable Class
Join Overload
System.Linq Namespace


Join(TOuter, TInner, TKey, TResult) Method (ParallelQuery(TOuter), ParallelQuery(TInner), Func(TOuter, TKey), Func(TInner, TKey), Func(TOuter, TInner, TResult))

[image]

.NET Framework Class Library
ParallelEnumerable..::.Join<(Of <(TOuter, TInner, TKey, TResult>)>) Method (ParallelQuery<(Of <(TOuter>)>), ParallelQuery<(Of <(TInner>)>), Func<(Of <(TOuter, TKey>)>), Func<(Of <(TInner, TKey>)>), Func<(Of <(TOuter, TInner, TResult>)>))
ParallelEnumerable Class See Also Send Feedback

Correlates in parallel the elements of two sequences based on matching keys. The default equality comparer is used to compare keys.

Namespace: System.Linq
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function Join(Of TOuter, TInner, TKey, TResult) ( _
    outer As ParallelQuery(Of TOuter), _
    inner As ParallelQuery(Of TInner), _
    outerKeySelector As Func(Of TOuter, TKey), _
    innerKeySelector As Func(Of TInner, TKey), _
    resultSelector As Func(Of TOuter, TInner, TResult) _
) As ParallelQuery(Of TResult)
C#
public static ParallelQuery<TResult> Join<TOuter, TInner, TKey, TResult>(
    ParallelQuery<TOuter> outer,
    ParallelQuery<TInner> inner,
    Func<TOuter, TKey> outerKeySelector,
    Func<TInner, TKey> innerKeySelector,
    Func<TOuter, TInner, TResult> resultSelector
)

Parameters

outer
Type: System.Linq..::.ParallelQuery <(Of <(TOuter>)>)
The first sequence to join.
inner
Type: System.Linq..::.ParallelQuery <(Of <(TInner>)>)
The sequence to join to the first sequence.
outerKeySelector
Type: System..::.Func<(Of <(TOuter, TKey>)>)
A function to extract the join key from each element of the first sequence.
innerKeySelector
Type: System..::.Func<(Of <(TInner, TKey>)>)
A function to extract the join key from each element of the second sequence.
resultSelector
Type: System..::.Func<(Of <(TOuter, TInner, TResult>)>)
A function to create a result element from two matching elements.

Type Parameters

TOuter
The type of the elements of the first sequence.
TInner
The type of the elements of the second sequence.
TKey
The type of the keys returned by the key selector functions.
TResult
The type of the result elements.

Return Value

A sequence that has elements of type TResult that are obtained by performing an inner join on two sequences.

Exceptions

Exception | Condition
System..::.ArgumentNullException | outer or inner or outerKeySelector or innerKeySelector or resultSelector is a null reference (Nothing in Visual Basic).

See Also

ParallelEnumerable Class
Join Overload
System.Linq Namespace


Join(TOuter, TInner, TKey, TResult) Method (ParallelQuery(TOuter), IEnumerable(TInner), Func(TOuter, TKey), Func(TInner, TKey), Func(TOuter, TInner, TResult), IEqualityComparer(TKey))

[image]

.NET Framework Class Library
ParallelEnumerable..::.Join<(Of <(TOuter, TInner, TKey, TResult>)>) Method (ParallelQuery<(Of <(TOuter>)>), IEnumerable<(Of <(TInner>)>), Func<(Of <(TOuter, TKey>)>), Func<(Of <(TInner, TKey>)>), Func<(Of <(TOuter, TInner, TResult>)>), IEqualityComparer<(Of <(TKey>)>))
ParallelEnumerable Class See Also Send Feedback

This Join overload should never be called. This method is marked as obsolete and always throws NotSupportedException when invoked.

Namespace: System.Linq
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
<ObsoleteAttribute("The second data source of a binary operator must be of type System.Linq.ParallelQuery<T> rather than System.Collections.Generic.IEnumerable<T>. To fix this problem, use the AsParallel() extension method to convert the right data source to System.Linq.ParallelQuery<T>.")> _
Public Shared Function Join(Of TOuter, TInner, TKey, TResult) ( _
    outer As ParallelQuery(Of TOuter), _
    inner As IEnumerable(Of TInner), _
    outerKeySelector As Func(Of TOuter, TKey), _
    innerKeySelector As Func(Of TInner, TKey), _
    resultSelector As Func(Of TOuter, TInner, TResult), _
    comparer As IEqualityComparer(Of TKey) _
) As ParallelQuery(Of TResult)
C#
[ObsoleteAttribute("The second data source of a binary operator must be of type System.Linq.ParallelQuery<T> rather than System.Collections.Generic.IEnumerable<T>. To fix this problem, use the AsParallel() extension method to convert the right data source to System.Linq.ParallelQuery<T>.")]
public static ParallelQuery<TResult> Join<TOuter, TInner, TKey, TResult>(
    ParallelQuery<TOuter> outer,
    IEnumerable<TInner> inner,
    Func<TOuter, TKey> outerKeySelector,
    Func<TInner, TKey> innerKeySelector,
    Func<TOuter, TInner, TResult> resultSelector,
    IEqualityComparer<TKey> comparer
)

Parameters

outer
Type: System.Linq..::.ParallelQuery <(Of <(TOuter>)>)
This parameter is not used.
inner
Type: System.Collections.Generic..::.IEnumerable<(Of <(TInner>)>)
This parameter is not used.
outerKeySelector
Type: System..::.Func<(Of <(TOuter, TKey>)>)
This parameter is not used.
innerKeySelector
Type: System..::.Func<(Of <(TInner, TKey>)>)
This parameter is not used.
resultSelector
Type: System..::.Func<(Of <(TOuter, TInner, TResult>)>)
This parameter is not used.
comparer
Type: System.Collections.Generic..::.IEqualityComparer<(Of <(TKey>)>)
This parameter is not used.

Type Parameters

TOuter
This type parameter is not used.
TInner
This type parameter is not used.
TKey
This type parameter is not used.
TResult
This type parameter is not used.

Return Value

This overload always throws a NotSupportedException.

Remarks

This overload exists to disallow usage of Join with a left data source of type ParallelQuery<(Of <(TSource>)>) and a right data source of type IEnumerable<(Of <(T>)>). Otherwise, the Join operator would appear to be binding to the parallel implementation, but would in reality bind to the sequential implementation.

Exceptions

Exception | Condition
System..::.NotSupportedException | The exception that occurs when this method is called.

See Also

ParallelEnumerable Class
Join Overload
System.Linq Namespace


Join(TOuter, TInner, TKey, TResult) Method (ParallelQuery(TOuter), ParallelQuery(TInner), Func(TOuter, TKey), Func(TInner, TKey), Func(TOuter, TInner, TResult), IEqualityComparer(TKey))

[image]

.NET Framework Class Library
ParallelEnumerable..::.Join<(Of <(TOuter, TInner, TKey, TResult>)>) Method (ParallelQuery<(Of <(TOuter>)>), ParallelQuery<(Of <(TInner>)>), Func<(Of <(TOuter, TKey>)>), Func<(Of <(TInner, TKey>)>), Func<(Of <(TOuter, TInner, TResult>)>), IEqualityComparer<(Of <(TKey>)>))
ParallelEnumerable Class See Also Send Feedback

Correlates in parallel the elements of two sequences based on matching keys. A specified IEqualityComparer{T} is used to compare keys.

Namespace: System.Linq
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function Join(Of TOuter, TInner, TKey, TResult) ( _
    outer As ParallelQuery(Of TOuter), _
    inner As ParallelQuery(Of TInner), _
    outerKeySelector As Func(Of TOuter, TKey), _
    innerKeySelector As Func(Of TInner, TKey), _
    resultSelector As Func(Of TOuter, TInner, TResult), _
    comparer As IEqualityComparer(Of TKey) _
) As ParallelQuery(Of TResult)
C#
public static ParallelQuery<TResult> Join<TOuter, TInner, TKey, TResult>(
    ParallelQuery<TOuter> outer,
    ParallelQuery<TInner> inner,
    Func<TOuter, TKey> outerKeySelector,
    Func<TInner, TKey> innerKeySelector,
    Func<TOuter, TInner, TResult> resultSelector,
    IEqualityComparer<TKey> comparer
)

Parameters

outer
Type: System.Linq..::.ParallelQuery <(Of <(TOuter>)>)
The first sequence to join.
inner
Type: System.Linq..::.ParallelQuery <(Of <(TInner>)>)
The sequence to join to the first sequence.
outerKeySelector
Type: System..::.Func<(Of <(TOuter, TKey>)>)
A function to extract the join key from each element of the first sequence.
innerKeySelector
Type: System..::.Func<(Of <(TInner, TKey>)>)
A function to extract the join key from each element of the second sequence.
resultSelector
Type: System..::.Func<(Of <(TOuter, TInner, TResult>)>)
A function to create a result element from two matching elements.
comparer
Type: System.Collections.Generic..::.IEqualityComparer<(Of <(TKey>)>)
An IEqualityComparer<(Of <(T>)>) to hash and compare keys.

Type Parameters

TOuter
The type of the elements of the first sequence.
TInner
The type of the elements of the second sequence.
TKey
The type of the keys returned by the key selector functions.
TResult
The type of the result elements.

Return Value

A sequence that has elements of type TResult that are obtained by performing an inner join on two sequences.

Exceptions

Exception | Condition
System..::.ArgumentNullException | outer or inner or outerKeySelector or innerKeySelector or resultSelector is a null reference (Nothing in Visual Basic).

See Also

ParallelEnumerable Class
Join Overload
System.Linq Namespace


Last Method

[image] [image]

.NET Framework Class Library
ParallelEnumerable..::.Last Method
ParallelEnumerable Class See Also Send Feedback

Overload List

Name | Description
Last<(Of <(TSource>)>)(ParallelQuery<(Of <(TSource>)>)) | Returns the last element of a parallel sequence.
Last<(Of <(TSource>)>)(ParallelQuery<(Of <(TSource>)>), Func<(Of <(TSource, Boolean>)>)) | Returns the last element of a parallel sequence that satisfies a specified condition.

See Also

ParallelEnumerable Class
System.Linq Namespace


Last(TSource) Method (ParallelQuery(TSource))

[image]

.NET Framework Class Library
ParallelEnumerable..::.Last<(Of <(TSource>)>) Method (ParallelQuery<(Of <(TSource>)>))
ParallelEnumerable Class See Also Send Feedback

Returns the last element of a parallel sequence.

Namespace: System.Linq
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function Last(Of TSource) ( _
    source As ParallelQuery(Of TSource) _
) As TSource
C#
public static TSource Last<TSource>(
    ParallelQuery<TSource> source
)

Parameters

source
Type: System.Linq..::.ParallelQuery <(Of <(TSource>)>)
The sequence to return the last element from.

Type Parameters

TSource
The type of the elements of source.

Return Value

The value at the last position in the source sequence.

Exceptions

Exception | Condition
System..::.ArgumentNullException | source is a null reference (Nothing in Visual Basic).
System..::.InvalidOperationException | source contains no elements.
System..::.AggregateException | One or more exceptions occurred during the evaluation of the query.
System..::.OperationCanceledException | The query was canceled.

See Also

ParallelEnumerable Class
Last Overload
System.Linq Namespace


Last(TSource) Method (ParallelQuery(TSource), Func(TSource, Boolean))

[image]

.NET Framework Class Library
ParallelEnumerable..::.Last<(Of <(TSource>)>) Method (ParallelQuery<(Of <(TSource>)>), Func<(Of <(TSource, Boolean>)>))
ParallelEnumerable Class See Also Send Feedback

Returns the last element of a parallel sequence that satisfies a specified condition.

Namespace: System.Linq
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function Last(Of TSource) ( _
    source As ParallelQuery(Of TSource), _
    predicate As Func(Of TSource, Boolean) _
) As TSource
C#
public static TSource Last<TSource>(
    ParallelQuery<TSource> source,
    Func<TSource, bool> predicate
)

Parameters

source
Type: System.Linq..::.ParallelQuery <(Of <(TSource>)>)
The sequence to return an element from.
predicate
Type: System..::.Func<(Of <(TSource, Boolean>)>)
A function to test each element for a condition.

Type Parameters

TSource
The type of the elements of source.

Return Value

The last element in the sequence that passes the test in the specified predicate function.

Exceptions

Exception | Condition
System..::.ArgumentNullException | source or predicate is a null reference (Nothing in Visual Basic).
System..::.InvalidOperationException | No element in source satisfies the condition in predicate.
System..::.AggregateException | One or more exceptions occurred during the evaluation of the query.
System..::.OperationCanceledException | The query was canceled.

See Also

ParallelEnumerable Class
Last Overload
System.Linq Namespace


LastOrDefault Method

[image] [image]

.NET Framework Class Library
ParallelEnumerable..::.LastOrDefault Method
ParallelEnumerable Class See Also Send Feedback

Overload List

Name | Description
LastOrDefault<(Of <(TSource>)>)(ParallelQuery<(Of <(TSource>)>)) | Returns the last element of a parallel sequence, or a default value if the sequence contains no elements.
LastOrDefault<(Of <(TSource>)>)(ParallelQuery<(Of <(TSource>)>), Func<(Of <(TSource, Boolean>)>)) | Returns the last element of a parallel sequence that satisfies a condition, or a default value if no such element is found.

See Also

ParallelEnumerable Class
System.Linq Namespace


LastOrDefault(TSource) Method (ParallelQuery(TSource))

[image]

.NET Framework Class Library
ParallelEnumerable..::.LastOrDefault<(Of <(TSource>)>) Method (ParallelQuery<(Of <(TSource>)>))
ParallelEnumerable Class See Also Send Feedback

Returns the last element of a parallel sequence, or a default value if the sequence contains no elements.

Namespace: System.Linq
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function LastOrDefault(Of TSource) ( _
    source As ParallelQuery(Of TSource) _
) As TSource
C#
public static TSource LastOrDefault<TSource>(
    ParallelQuery<TSource> source
)

Parameters

source
Type: System.Linq..::.ParallelQuery <(Of <(TSource>)>)
The sequence to return an element from.

Type Parameters

TSource
The type of the elements of source.

Return Value

default(TSource) if the source sequence is empty; otherwise, the last element in the sequence.

Exceptions

Exception | Condition
System..::.ArgumentNullException | source is a null reference (Nothing in Visual Basic).
System..::.AggregateException | One or more exceptions occurred during the evaluation of the query.
System..::.OperationCanceledException | The query was canceled.

See Also

ParallelEnumerable Class
LastOrDefault Overload
System.Linq Namespace


LastOrDefault(TSource) Method (ParallelQuery(TSource), Func(TSource, Boolean))

[image]

.NET Framework Class Library
ParallelEnumerable..::.LastOrDefault<(Of <(TSource>)>) Method (ParallelQuery<(Of <(TSource>)>), Func<(Of <(TSource, Boolean>)>))
ParallelEnumerable Class See Also Send Feedback

Returns the last element of a parallel sequence that satisfies a condition, or a default value if no such element is found.

Namespace: System.Linq
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function LastOrDefault(Of TSource) ( _
    source As ParallelQuery(Of TSource), _
    predicate As Func(Of TSource, Boolean) _
) As TSource
C#
public static TSource LastOrDefault<TSource>(
    ParallelQuery<TSource> source,
    Func<TSource, bool> predicate
)

Parameters

source
Type: System.Linq..::.ParallelQuery <(Of <(TSource>)>)
The sequence to return an element from.
predicate
Type: System..::.Func<(Of <(TSource, Boolean>)>)
A function to test each element for a condition.

Type Parameters

TSource
The type of the elements of source.

Return Value

default(TSource) if the sequence is empty or if no elements pass the test in the predicate function; otherwise, the last element that passes the test in the predicate function.

Exceptions

Exception | Condition
System..::.ArgumentNullException | source or predicate is a null reference (Nothing in Visual Basic).
System..::.AggregateException | One or more exceptions occurred during the evaluation of the query.
System..::.OperationCanceledException | The query was canceled.

See Also

ParallelEnumerable Class
LastOrDefault Overload
System.Linq Namespace


LongCount Method

[image] [image]

.NET Framework Class Library
ParallelEnumerable..::.LongCount Method
ParallelEnumerable Class See Also Send Feedback

Overload List

Name | Description
LongCount<(Of <(TSource>)>)(ParallelQuery<(Of <(TSource>)>)) | Returns an Int64 that represents the total number of elements in a parallel sequence.
LongCount<(Of <(TSource>)>)(ParallelQuery<(Of <(TSource>)>), Func<(Of <(TSource, Boolean>)>)) | Returns an Int64 that represents how many elements in a parallel sequence satisfy a condition.

See Also

ParallelEnumerable Class
System.Linq Namespace


LongCount(TSource) Method (ParallelQuery(TSource))

[image]

.NET Framework Class Library
ParallelEnumerable..::.LongCount<(Of <(TSource>)>) Method (ParallelQuery<(Of <(TSource>)>))
ParallelEnumerable Class See Also Send Feedback

Returns an Int64 that represents the total number of elements in a parallel sequence.

Namespace: System.Linq
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function LongCount(Of TSource) ( _
    source As ParallelQuery(Of TSource) _
) As Long
C#
public static long LongCount<TSource>(
    ParallelQuery<TSource> source
)

Parameters

source
Type: System.Linq..::.ParallelQuery <(Of <(TSource>)>)
A sequence that contains elements to be counted.

Type Parameters

TSource
The type of the elements of source.

Return Value

The number of elements in the input sequence.

Exceptions

Exception | Condition
System..::.ArgumentNullException | source is a null reference (Nothing in Visual Basic).
System..::.AggregateException | The number of elements in source is larger than MaxValue()()(). -or- One or more exceptions occurred during the evaluation of the query.
System..::.OperationCanceledException | The query was canceled.

See Also

ParallelEnumerable Class
LongCount Overload
System.Linq Namespace


LongCount(TSource) Method (ParallelQuery(TSource), Func(TSource, Boolean))

[image]

.NET Framework Class Library
ParallelEnumerable..::.LongCount<(Of <(TSource>)>) Method (ParallelQuery<(Of <(TSource>)>), Func<(Of <(TSource, Boolean>)>))
ParallelEnumerable Class See Also Send Feedback

Returns an Int64 that represents how many elements in a parallel sequence satisfy a condition.

Namespace: System.Linq
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function LongCount(Of TSource) ( _
    source As ParallelQuery(Of TSource), _
    predicate As Func(Of TSource, Boolean) _
) As Long
C#
public static long LongCount<TSource>(
    ParallelQuery<TSource> source,
    Func<TSource, bool> predicate
)

Parameters

source
Type: System.Linq..::.ParallelQuery <(Of <(TSource>)>)
A sequence that contains elements to be counted.
predicate
Type: System..::.Func<(Of <(TSource, Boolean>)>)
A function to test each element for a condition.

Type Parameters

TSource
The type of the elements of source.

Return Value

A number that represents how many elements in the sequence satisfy the condition in the predicate function.

Exceptions

Exception | Condition
System..::.ArgumentNullException | source or predicate is a null reference (Nothing in Visual Basic).
System..::.AggregateException | The number of elements in source is larger than MaxValue()()(). -or- One or more exceptions occurred during the evaluation of the query.
System..::.OperationCanceledException | The query was canceled.

See Also

ParallelEnumerable Class
LongCount Overload
System.Linq Namespace


Max Method

[image] [image]

.NET Framework Class Library
ParallelEnumerable..::.Max Method
ParallelEnumerable Class See Also Send Feedback

Overload List

Name | Description
Max(ParallelQuery<(Of <(Decimal>)>)) | Returns the maximum value in a parallel sequence of values.
Max(ParallelQuery<(Of <(Double>)>)) | Returns the maximum value in a parallel sequence of values.
Max(ParallelQuery<(Of <(Int32>)>)) | Returns the maximum value in a parallel sequence of values.
Max(ParallelQuery<(Of <(Int64>)>)) | Returns the maximum value in a parallel sequence of values.
Max(ParallelQuery<(Of <(Nullable<(Of <(Decimal>)>)>)>)) | Returns the maximum value in a parallel sequence of values.
Max(ParallelQuery<(Of <(Nullable<(Of <(Double>)>)>)>)) | Returns the maximum value in a parallel sequence of values.
Max(ParallelQuery<(Of <(Nullable<(Of <(Int32>)>)>)>)) | Returns the maximum value in a parallel sequence of values.
Max(ParallelQuery<(Of <(Nullable<(Of <(Int64>)>)>)>)) | Returns the maximum value in a parallel sequence of values.
Max(ParallelQuery<(Of <(Nullable<(Of <(Single>)>)>)>)) | Returns the maximum value in a parallel sequence of values.
Max(ParallelQuery<(Of <(Single>)>)) | Returns the maximum value in a parallel sequence of values.
Max<(Of <(TSource>)>)(ParallelQuery<(Of <(TSource>)>)) | Returns the maximum value in a parallel sequence of values.
Max<(Of <(TSource>)>)(ParallelQuery<(Of <(TSource>)>), Func<(Of <(TSource, Decimal>)>)) | Invokes in parallel a transform function on each element of a sequence and returns the maximum value.
Max<(Of <(TSource>)>)(ParallelQuery<(Of <(TSource>)>), Func<(Of <(TSource, Double>)>)) | Invokes in parallel a transform function on each element of a sequence and returns the maximum value.
Max<(Of <(TSource>)>)(ParallelQuery<(Of <(TSource>)>), Func<(Of <(TSource, Int32>)>)) | Invokes in parallel a transform function on each element of a sequence and returns the maximum value.
Max<(Of <(TSource>)>)(ParallelQuery<(Of <(TSource>)>), Func<(Of <(TSource, Int64>)>)) | Invokes in parallel a transform function on each element of a sequence and returns the maximum value.
Max<(Of <(TSource>)>)(ParallelQuery<(Of <(TSource>)>), Func<(Of <(TSource, Nullable<(Of <(Decimal>)>)>)>)) | Invokes in parallel a transform function on each element of a sequence and returns the maximum value.
Max<(Of <(TSource>)>)(ParallelQuery<(Of <(TSource>)>), Func<(Of <(TSource, Nullable<(Of <(Double>)>)>)>)) | Invokes in parallel a transform function on each element of a sequence and returns the maximum value.
Max<(Of <(TSource>)>)(ParallelQuery<(Of <(TSource>)>), Func<(Of <(TSource, Nullable<(Of <(Int32>)>)>)>)) | Invokes in parallel a transform function on each element of a sequence and returns the maximum value.
Max<(Of <(TSource>)>)(ParallelQuery<(Of <(TSource>)>), Func<(Of <(TSource, Nullable<(Of <(Int64>)>)>)>)) | Invokes in parallel a transform function on each element of a sequence and returns the maximum value.
Max<(Of <(TSource>)>)(ParallelQuery<(Of <(TSource>)>), Func<(Of <(TSource, Nullable<(Of <(Single>)>)>)>)) | Invokes in parallel a transform function on each element of a sequence and returns the maximum value.
Max<(Of <(TSource>)>)(ParallelQuery<(Of <(TSource>)>), Func<(Of <(TSource, Single>)>)) | Invokes in parallel a transform function on each element of a sequence and returns the maximum value.
Max<(Of <(TSource, TResult>)>)(ParallelQuery<(Of <(TSource>)>), Func<(Of <(TSource, TResult>)>)) | Invokes in parallel a transform function on each element of a sequence and returns the maximum value.

See Also

ParallelEnumerable Class
System.Linq Namespace


Max Method (ParallelQuery(Decimal))

[image]

.NET Framework Class Library
ParallelEnumerable..::.Max Method (ParallelQuery<(Of <(Decimal>)>))
ParallelEnumerable Class See Also Send Feedback

Returns the maximum value in a parallel sequence of values.

Namespace: System.Linq
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function Max ( _
    source As ParallelQuery(Of Decimal) _
) As Decimal
C#
public static decimal Max(
    ParallelQuery<decimal> source
)

Parameters

source
Type: System.Linq..::.ParallelQuery <(Of <(Decimal>)>)
A sequence of values to determine the maximum value of.

Return Value

The maximum value in the sequence.

Exceptions

Exception | Condition
System..::.ArgumentNullException | source is a null reference (Nothing in Visual Basic).
System..::.InvalidOperationException | source contains no elements.
System..::.AggregateException | One or more exceptions occurred during the evaluation of the query.
System..::.OperationCanceledException | The query was canceled.

See Also

ParallelEnumerable Class
Max Overload
System.Linq Namespace


Max Method (ParallelQuery(Double))

[image]

.NET Framework Class Library
ParallelEnumerable..::.Max Method (ParallelQuery<(Of <(Double>)>))
ParallelEnumerable Class See Also Send Feedback

Returns the maximum value in a parallel sequence of values.

Namespace: System.Linq
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function Max ( _
    source As ParallelQuery(Of Double) _
) As Double
C#
public static double Max(
    ParallelQuery<double> source
)

Parameters

source
Type: System.Linq..::.ParallelQuery <(Of <(Double>)>)
A sequence of values to determine the maximum value of.

Return Value

The maximum value in the sequence.

Exceptions

Exception | Condition
System..::.ArgumentNullException | source is a null reference (Nothing in Visual Basic).
System..::.InvalidOperationException | source contains no elements.
System..::.AggregateException | One or more exceptions occurred during the evaluation of the query.
System..::.OperationCanceledException | The query was canceled.

See Also

ParallelEnumerable Class
Max Overload
System.Linq Namespace


Max Method (ParallelQuery(Int32))

[image]

.NET Framework Class Library
ParallelEnumerable..::.Max Method (ParallelQuery<(Of <(Int32>)>))
ParallelEnumerable Class See Also Send Feedback

Returns the maximum value in a parallel sequence of values.

Namespace: System.Linq
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function Max ( _
    source As ParallelQuery(Of Integer) _
) As Integer
C#
public static int Max(
    ParallelQuery<int> source
)

Parameters

source
Type: System.Linq..::.ParallelQuery <(Of <(Int32>)>)
A sequence of values to determine the maximum value of.

Return Value

The maximum value in the sequence.

Exceptions

Exception | Condition
System..::.ArgumentNullException | source is a null reference (Nothing in Visual Basic).
System..::.InvalidOperationException | source contains no elements.
System..::.AggregateException | One or more exceptions occurred during the evaluation of the query.
System..::.OperationCanceledException | The query was canceled.

See Also

ParallelEnumerable Class
Max Overload
System.Linq Namespace


Max Method (ParallelQuery(Int64))

[image]

.NET Framework Class Library
ParallelEnumerable..::.Max Method (ParallelQuery<(Of <(Int64>)>))
ParallelEnumerable Class See Also Send Feedback

Returns the maximum value in a parallel sequence of values.

Namespace: System.Linq
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function Max ( _
    source As ParallelQuery(Of Long) _
) As Long
C#
public static long Max(
    ParallelQuery<long> source
)

Parameters

source
Type: System.Linq..::.ParallelQuery <(Of <(Int64>)>)
A sequence of values to determine the maximum value of.

Return Value

The maximum value in the sequence.

Exceptions

Exception | Condition
System..::.ArgumentNullException | source is a null reference (Nothing in Visual Basic).
System..::.InvalidOperationException | source contains no elements.
System..::.AggregateException | One or more exceptions occurred during the evaluation of the query.
System..::.OperationCanceledException | The query was canceled.

See Also

ParallelEnumerable Class
Max Overload
System.Linq Namespace


Max Method (ParallelQuery(Nullable(Decimal)))

[image]

.NET Framework Class Library
ParallelEnumerable..::.Max Method (ParallelQuery<(Of <(Nullable<(Of <(Decimal>)>)>)>))
ParallelEnumerable Class See Also Send Feedback

Returns the maximum value in a parallel sequence of values.

Namespace: System.Linq
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function Max ( _
    source As ParallelQuery(Of Nullable(Of Decimal)) _
) As Nullable(Of Decimal)
C#
public static Nullable<decimal> Max(
    ParallelQuery<Nullable<decimal>> source
)

Parameters

source
Type: System.Linq..::.ParallelQuery <(Of <(Nullable<(Of <(Decimal>)>)>)>)
A sequence of values to determine the maximum value of.

Return Value

The maximum value in the sequence.

Exceptions

Exception | Condition
System..::.ArgumentNullException | source is a null reference (Nothing in Visual Basic).
System..::.AggregateException | One or more exceptions occurred during the evaluation of the query.
System..::.OperationCanceledException | The query was canceled.

See Also

ParallelEnumerable Class
Max Overload
System.Linq Namespace


Max Method (ParallelQuery(Nullable(Double)))

[image]

.NET Framework Class Library
ParallelEnumerable..::.Max Method (ParallelQuery<(Of <(Nullable<(Of <(Double>)>)>)>))
ParallelEnumerable Class See Also Send Feedback

Returns the maximum value in a parallel sequence of values.

Namespace: System.Linq
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function Max ( _
    source As ParallelQuery(Of Nullable(Of Double)) _
) As Nullable(Of Double)
C#
public static Nullable<double> Max(
    ParallelQuery<Nullable<double>> source
)

Parameters

source
Type: System.Linq..::.ParallelQuery <(Of <(Nullable<(Of <(Double>)>)>)>)
A sequence of values to determine the maximum value of.

Return Value

The maximum value in the sequence.

Exceptions

Exception | Condition
System..::.ArgumentNullException | source is a null reference (Nothing in Visual Basic).
System..::.AggregateException | One or more exceptions occurred during the evaluation of the query.
System..::.OperationCanceledException | The query was canceled.

See Also

ParallelEnumerable Class
Max Overload
System.Linq Namespace


Max Method (ParallelQuery(Nullable(Int32)))

[image]

.NET Framework Class Library
ParallelEnumerable..::.Max Method (ParallelQuery<(Of <(Nullable<(Of <(Int32>)>)>)>))
ParallelEnumerable Class See Also Send Feedback

Returns the maximum value in a parallel sequence of values.

Namespace: System.Linq
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function Max ( _
    source As ParallelQuery(Of Nullable(Of Integer)) _
) As Nullable(Of Integer)
C#
public static Nullable<int> Max(
    ParallelQuery<Nullable<int>> source
)

Parameters

source
Type: System.Linq..::.ParallelQuery <(Of <(Nullable<(Of <(Int32>)>)>)>)
A sequence of values to determine the maximum value of.

Return Value

The maximum value in the sequence.

Exceptions

Exception | Condition
System..::.ArgumentNullException | source is a null reference (Nothing in Visual Basic).
System..::.AggregateException | One or more exceptions occurred during the evaluation of the query.
System..::.OperationCanceledException | The query was canceled.

See Also

ParallelEnumerable Class
Max Overload
System.Linq Namespace


Max Method (ParallelQuery(Nullable(Int64)))

[image]

.NET Framework Class Library
ParallelEnumerable..::.Max Method (ParallelQuery<(Of <(Nullable<(Of <(Int64>)>)>)>))
ParallelEnumerable Class See Also Send Feedback

Returns the maximum value in a parallel sequence of values.

Namespace: System.Linq
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function Max ( _
    source As ParallelQuery(Of Nullable(Of Long)) _
) As Nullable(Of Long)
C#
public static Nullable<long> Max(
    ParallelQuery<Nullable<long>> source
)

Parameters

source
Type: System.Linq..::.ParallelQuery <(Of <(Nullable<(Of <(Int64>)>)>)>)
A sequence of values to determine the maximum value of.

Return Value

The maximum value in the sequence.

Exceptions

Exception | Condition
System..::.ArgumentNullException | source is a null reference (Nothing in Visual Basic).
System..::.AggregateException | One or more exceptions occurred during the evaluation of the query.
System..::.OperationCanceledException | The query was canceled.

See Also

ParallelEnumerable Class
Max Overload
System.Linq Namespace


Max Method (ParallelQuery(Nullable(Single)))

[image]

.NET Framework Class Library
ParallelEnumerable..::.Max Method (ParallelQuery<(Of <(Nullable<(Of <(Single>)>)>)>))
ParallelEnumerable Class See Also Send Feedback

Returns the maximum value in a parallel sequence of values.

Namespace: System.Linq
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function Max ( _
    source As ParallelQuery(Of Nullable(Of Single)) _
) As Nullable(Of Single)
C#
public static Nullable<float> Max(
    ParallelQuery<Nullable<float>> source
)

Parameters

source
Type: System.Linq..::.ParallelQuery <(Of <(Nullable<(Of <(Single>)>)>)>)
A sequence of values to determine the maximum value of.

Return Value

The maximum value in the sequence.

Exceptions

Exception | Condition
System..::.ArgumentNullException | source is a null reference (Nothing in Visual Basic).
System..::.AggregateException | One or more exceptions occurred during the evaluation of the query.
System..::.OperationCanceledException | The query was canceled.

See Also

ParallelEnumerable Class
Max Overload
System.Linq Namespace


Max Method (ParallelQuery(Single))

[image]

.NET Framework Class Library
ParallelEnumerable..::.Max Method (ParallelQuery<(Of <(Single>)>))
ParallelEnumerable Class See Also Send Feedback

Returns the maximum value in a parallel sequence of values.

Namespace: System.Linq
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function Max ( _
    source As ParallelQuery(Of Single) _
) As Single
C#
public static float Max(
    ParallelQuery<float> source
)

Parameters

source
Type: System.Linq..::.ParallelQuery <(Of <(Single>)>)
A sequence of values to determine the maximum value of.

Return Value

The maximum value in the sequence.

Exceptions

Exception | Condition
System..::.ArgumentNullException | source is a null reference (Nothing in Visual Basic).
System..::.InvalidOperationException | source contains no elements.
System..::.AggregateException | One or more exceptions occurred during the evaluation of the query.
System..::.OperationCanceledException | The query was canceled.

See Also

ParallelEnumerable Class
Max Overload
System.Linq Namespace


Max(TSource) Method (ParallelQuery(TSource))

[image]

.NET Framework Class Library
ParallelEnumerable..::.Max<(Of <(TSource>)>) Method (ParallelQuery<(Of <(TSource>)>))
ParallelEnumerable Class See Also Send Feedback

Returns the maximum value in a parallel sequence of values.

Namespace: System.Linq
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function Max(Of TSource) ( _
    source As ParallelQuery(Of TSource) _
) As TSource
C#
public static TSource Max<TSource>(
    ParallelQuery<TSource> source
)

Parameters

source
Type: System.Linq..::.ParallelQuery <(Of <(TSource>)>)
A sequence of values to determine the maximum value of.

Type Parameters

TSource

Return Value

The maximum value in the sequence.

Exceptions

Exception | Condition
System..::.ArgumentNullException | source is a null reference (Nothing in Visual Basic).
System..::.InvalidOperationException | source contains no elements and is a non-nullable value type.
System..::.AggregateException | One or more exceptions occurred during the evaluation of the query.
System..::.OperationCanceledException | The query was canceled.

See Also

ParallelEnumerable Class
Max Overload
System.Linq Namespace


Max(TSource) Method (ParallelQuery(TSource), Func(TSource, Decimal))

[image]

.NET Framework Class Library
ParallelEnumerable..::.Max<(Of <(TSource>)>) Method (ParallelQuery<(Of <(TSource>)>), Func<(Of <(TSource, Decimal>)>))
ParallelEnumerable Class See Also Send Feedback

Invokes in parallel a transform function on each element of a sequence and returns the maximum value.

Namespace: System.Linq
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function Max(Of TSource) ( _
    source As ParallelQuery(Of TSource), _
    selector As Func(Of TSource, Decimal) _
) As Decimal
C#
public static decimal Max<TSource>(
    ParallelQuery<TSource> source,
    Func<TSource, decimal> selector
)

Parameters

source
Type: System.Linq..::.ParallelQuery <(Of <(TSource>)>)
A sequence of values to determine the maximum value of.
selector
Type: System..::.Func<(Of <(TSource, Decimal>)>)
A transform function to apply to each element.

Type Parameters

TSource
The type of elements of source.

Return Value

The maximum value in the sequence.

Exceptions

Exception | Condition
System..::.ArgumentNullException | source or selector is a null reference (Nothing in Visual Basic).
System..::.InvalidOperationException | source contains no elements.
System..::.AggregateException | One or more exceptions occurred during the evaluation of the query.
System..::.OperationCanceledException | The query was canceled.

See Also

ParallelEnumerable Class
Max Overload
System.Linq Namespace


Max(TSource) Method (ParallelQuery(TSource), Func(TSource, Double))

[image]

.NET Framework Class Library
ParallelEnumerable..::.Max<(Of <(TSource>)>) Method (ParallelQuery<(Of <(TSource>)>), Func<(Of <(TSource, Double>)>))
ParallelEnumerable Class See Also Send Feedback

Invokes in parallel a transform function on each element of a sequence and returns the maximum value.

Namespace: System.Linq
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function Max(Of TSource) ( _
    source As ParallelQuery(Of TSource), _
    selector As Func(Of TSource, Double) _
) As Double
C#
public static double Max<TSource>(
    ParallelQuery<TSource> source,
    Func<TSource, double> selector
)

Parameters

source
Type: System.Linq..::.ParallelQuery <(Of <(TSource>)>)
A sequence of values to determine the maximum value of.
selector
Type: System..::.Func<(Of <(TSource, Double>)>)
A transform function to apply to each element.

Type Parameters

TSource
The type of elements of source.

Return Value

The maximum value in the sequence.

Exceptions

Exception | Condition
System..::.ArgumentNullException | source or selector is a null reference (Nothing in Visual Basic).
System..::.InvalidOperationException | source contains no elements.
System..::.AggregateException | One or more exceptions occurred during the evaluation of the query.
System..::.OperationCanceledException | The query was canceled.

See Also

ParallelEnumerable Class
Max Overload
System.Linq Namespace


Max(TSource) Method (ParallelQuery(TSource), Func(TSource, Int32))

[image]

.NET Framework Class Library
ParallelEnumerable..::.Max<(Of <(TSource>)>) Method (ParallelQuery<(Of <(TSource>)>), Func<(Of <(TSource, Int32>)>))
ParallelEnumerable Class See Also Send Feedback

Invokes in parallel a transform function on each element of a sequence and returns the maximum value.

Namespace: System.Linq
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function Max(Of TSource) ( _
    source As ParallelQuery(Of TSource), _
    selector As Func(Of TSource, Integer) _
) As Integer
C#
public static int Max<TSource>(
    ParallelQuery<TSource> source,
    Func<TSource, int> selector
)

Parameters

source
Type: System.Linq..::.ParallelQuery <(Of <(TSource>)>)
A sequence of values to determine the maximum value of.
selector
Type: System..::.Func<(Of <(TSource, Int32>)>)
A transform function to apply to each element.

Type Parameters

TSource
The type of elements of source.

Return Value

The maximum value in the sequence.

Exceptions

Exception | Condition
System..::.ArgumentNullException | source or selector is a null reference (Nothing in Visual Basic).
System..::.InvalidOperationException | source contains no elements.
System..::.AggregateException | One or more exceptions occurred during the evaluation of the query.
System..::.OperationCanceledException | The query was canceled.

See Also

ParallelEnumerable Class
Max Overload
System.Linq Namespace


Max(TSource) Method (ParallelQuery(TSource), Func(TSource, Int64))

[image]

.NET Framework Class Library
ParallelEnumerable..::.Max<(Of <(TSource>)>) Method (ParallelQuery<(Of <(TSource>)>), Func<(Of <(TSource, Int64>)>))
ParallelEnumerable Class See Also Send Feedback

Invokes in parallel a transform function on each element of a sequence and returns the maximum value.

Namespace: System.Linq
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function Max(Of TSource) ( _
    source As ParallelQuery(Of TSource), _
    selector As Func(Of TSource, Long) _
) As Long
C#
public static long Max<TSource>(
    ParallelQuery<TSource> source,
    Func<TSource, long> selector
)

Parameters

source
Type: System.Linq..::.ParallelQuery <(Of <(TSource>)>)
A sequence of values to determine the maximum value of.
selector
Type: System..::.Func<(Of <(TSource, Int64>)>)
A transform function to apply to each element.

Type Parameters

TSource
The type of elements of source.

Return Value

The maximum value in the sequence.

Exceptions

Exception | Condition
System..::.ArgumentNullException | source or selector is a null reference (Nothing in Visual Basic).
System..::.InvalidOperationException | source contains no elements.
System..::.AggregateException | One or more exceptions occurred during the evaluation of the query.
System..::.OperationCanceledException | The query was canceled.

See Also

ParallelEnumerable Class
Max Overload
System.Linq Namespace


Max(TSource) Method (ParallelQuery(TSource), Func(TSource, Nullable(Decimal)))

[image]

.NET Framework Class Library
ParallelEnumerable..::.Max<(Of <(TSource>)>) Method (ParallelQuery<(Of <(TSource>)>), Func<(Of <(TSource, Nullable<(Of <(Decimal>)>)>)>))
ParallelEnumerable Class See Also Send Feedback

Invokes in parallel a transform function on each element of a sequence and returns the maximum value.

Namespace: System.Linq
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function Max(Of TSource) ( _
    source As ParallelQuery(Of TSource), _
    selector As Func(Of TSource, Nullable(Of Decimal)) _
) As Nullable(Of Decimal)
C#
public static Nullable<decimal> Max<TSource>(
    ParallelQuery<TSource> source,
    Func<TSource, Nullable<decimal>> selector
)

Parameters

source
Type: System.Linq..::.ParallelQuery <(Of <(TSource>)>)
A sequence of values to determine the maximum value of.
selector
Type: System..::.Func<(Of <(TSource, Nullable<(Of <(Decimal>)>)>)>)
A transform function to apply to each element.

Type Parameters

TSource
The type of elements of source.

Return Value

The maximum value in the sequence.

Exceptions

Exception | Condition
System..::.ArgumentNullException | source or selector is a null reference (Nothing in Visual Basic).
System..::.AggregateException | One or more exceptions occurred during the evaluation of the query.
System..::.OperationCanceledException | The query was canceled.

See Also

ParallelEnumerable Class
Max Overload
System.Linq Namespace


Max(TSource) Method (ParallelQuery(TSource), Func(TSource, Nullable(Double)))

[image]

.NET Framework Class Library
ParallelEnumerable..::.Max<(Of <(TSource>)>) Method (ParallelQuery<(Of <(TSource>)>), Func<(Of <(TSource, Nullable<(Of <(Double>)>)>)>))
ParallelEnumerable Class See Also Send Feedback

Invokes in parallel a transform function on each element of a sequence and returns the maximum value.

Namespace: System.Linq
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function Max(Of TSource) ( _
    source As ParallelQuery(Of TSource), _
    selector As Func(Of TSource, Nullable(Of Double)) _
) As Nullable(Of Double)
C#
public static Nullable<double> Max<TSource>(
    ParallelQuery<TSource> source,
    Func<TSource, Nullable<double>> selector
)

Parameters

source
Type: System.Linq..::.ParallelQuery <(Of <(TSource>)>)
A sequence of values to determine the maximum value of.
selector
Type: System..::.Func<(Of <(TSource, Nullable<(Of <(Double>)>)>)>)
A transform function to apply to each element.

Type Parameters

TSource
The type of elements of source.

Return Value

The maximum value in the sequence.

Exceptions

Exception | Condition
System..::.ArgumentNullException | source or selector is a null reference (Nothing in Visual Basic).
System..::.AggregateException | One or more exceptions occurred during the evaluation of the query.
System..::.OperationCanceledException | The query was canceled.

See Also

ParallelEnumerable Class
Max Overload
System.Linq Namespace


Max(TSource) Method (ParallelQuery(TSource), Func(TSource, Nullable(Int32)))

[image]

.NET Framework Class Library
ParallelEnumerable..::.Max<(Of <(TSource>)>) Method (ParallelQuery<(Of <(TSource>)>), Func<(Of <(TSource, Nullable<(Of <(Int32>)>)>)>))
ParallelEnumerable Class See Also Send Feedback

Invokes in parallel a transform function on each element of a sequence and returns the maximum value.

Namespace: System.Linq
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function Max(Of TSource) ( _
    source As ParallelQuery(Of TSource), _
    selector As Func(Of TSource, Nullable(Of Integer)) _
) As Nullable(Of Integer)
C#
public static Nullable<int> Max<TSource>(
    ParallelQuery<TSource> source,
    Func<TSource, Nullable<int>> selector
)

Parameters

source
Type: System.Linq..::.ParallelQuery <(Of <(TSource>)>)
A sequence of values to determine the maximum value of.
selector
Type: System..::.Func<(Of <(TSource, Nullable<(Of <(Int32>)>)>)>)
A transform function to apply to each element.

Type Parameters

TSource
The type of elements of source.

Return Value

The maximum value in the sequence.

Exceptions

Exception | Condition
System..::.ArgumentNullException | source or selector is a null reference (Nothing in Visual Basic).
System..::.AggregateException | One or more exceptions occurred during the evaluation of the query.
System..::.OperationCanceledException | The query was canceled.

See Also

ParallelEnumerable Class
Max Overload
System.Linq Namespace


Max(TSource) Method (ParallelQuery(TSource), Func(TSource, Nullable(Int64)))

[image]

.NET Framework Class Library
ParallelEnumerable..::.Max<(Of <(TSource>)>) Method (ParallelQuery<(Of <(TSource>)>), Func<(Of <(TSource, Nullable<(Of <(Int64>)>)>)>))
ParallelEnumerable Class See Also Send Feedback

Invokes in parallel a transform function on each element of a sequence and returns the maximum value.

Namespace: System.Linq
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function Max(Of TSource) ( _
    source As ParallelQuery(Of TSource), _
    selector As Func(Of TSource, Nullable(Of Long)) _
) As Nullable(Of Long)
C#
public static Nullable<long> Max<TSource>(
    ParallelQuery<TSource> source,
    Func<TSource, Nullable<long>> selector
)

Parameters

source
Type: System.Linq..::.ParallelQuery <(Of <(TSource>)>)
A sequence of values to determine the maximum value of.
selector
Type: System..::.Func<(Of <(TSource, Nullable<(Of <(Int64>)>)>)>)
A transform function to apply to each element.

Type Parameters

TSource
The type of elements of source.

Return Value

The maximum value in the sequence.

Exceptions

Exception | Condition
System..::.ArgumentNullException | source or selector is a null reference (Nothing in Visual Basic).
System..::.AggregateException | One or more exceptions occurred during the evaluation of the query.
System..::.OperationCanceledException | The query was canceled.

See Also

ParallelEnumerable Class
Max Overload
System.Linq Namespace


Max(TSource) Method (ParallelQuery(TSource), Func(TSource, Nullable(Single)))

[image]

.NET Framework Class Library
ParallelEnumerable..::.Max<(Of <(TSource>)>) Method (ParallelQuery<(Of <(TSource>)>), Func<(Of <(TSource, Nullable<(Of <(Single>)>)>)>))
ParallelEnumerable Class See Also Send Feedback

Invokes in parallel a transform function on each element of a sequence and returns the maximum value.

Namespace: System.Linq
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function Max(Of TSource) ( _
    source As ParallelQuery(Of TSource), _
    selector As Func(Of TSource, Nullable(Of Single)) _
) As Nullable(Of Single)
C#
public static Nullable<float> Max<TSource>(
    ParallelQuery<TSource> source,
    Func<TSource, Nullable<float>> selector
)

Parameters

source
Type: System.Linq..::.ParallelQuery <(Of <(TSource>)>)
A sequence of values to determine the maximum value of.
selector
Type: System..::.Func<(Of <(TSource, Nullable<(Of <(Single>)>)>)>)
A transform function to apply to each element.

Type Parameters

TSource
The type of elements of source.

Return Value

The maximum value in the sequence.

Exceptions

Exception | Condition
System..::.ArgumentNullException | source or selector is a null reference (Nothing in Visual Basic).
System..::.AggregateException | One or more exceptions occurred during the evaluation of the query.
System..::.OperationCanceledException | The query was canceled.

See Also

ParallelEnumerable Class
Max Overload
System.Linq Namespace


Max(TSource) Method (ParallelQuery(TSource), Func(TSource, Single))

[image]

.NET Framework Class Library
ParallelEnumerable..::.Max<(Of <(TSource>)>) Method (ParallelQuery<(Of <(TSource>)>), Func<(Of <(TSource, Single>)>))
ParallelEnumerable Class See Also Send Feedback

Invokes in parallel a transform function on each element of a sequence and returns the maximum value.

Namespace: System.Linq
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function Max(Of TSource) ( _
    source As ParallelQuery(Of TSource), _
    selector As Func(Of TSource, Single) _
) As Single
C#
public static float Max<TSource>(
    ParallelQuery<TSource> source,
    Func<TSource, float> selector
)

Parameters

source
Type: System.Linq..::.ParallelQuery <(Of <(TSource>)>)
A sequence of values to determine the maximum value of.
selector
Type: System..::.Func<(Of <(TSource, Single>)>)
A transform function to apply to each element.

Type Parameters

TSource
The type of elements of source.

Return Value

The maximum value in the sequence.

Exceptions

Exception | Condition
System..::.ArgumentNullException | source or selector is a null reference (Nothing in Visual Basic).
System..::.InvalidOperationException | source contains no elements.
System..::.AggregateException | One or more exceptions occurred during the evaluation of the query.
System..::.OperationCanceledException | The query was canceled.

See Also

ParallelEnumerable Class
Max Overload
System.Linq Namespace


Max(TSource, TResult) Method (ParallelQuery(TSource), Func(TSource, TResult))

[image]

.NET Framework Class Library
ParallelEnumerable..::.Max<(Of <(TSource, TResult>)>) Method (ParallelQuery<(Of <(TSource>)>), Func<(Of <(TSource, TResult>)>))
ParallelEnumerable Class See Also Send Feedback

Invokes in parallel a transform function on each element of a sequence and returns the maximum value.

Namespace: System.Linq
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function Max(Of TSource, TResult) ( _
    source As ParallelQuery(Of TSource), _
    selector As Func(Of TSource, TResult) _
) As TResult
C#
public static TResult Max<TSource, TResult>(
    ParallelQuery<TSource> source,
    Func<TSource, TResult> selector
)

Parameters

source
Type: System.Linq..::.ParallelQuery <(Of <(TSource>)>)
A sequence of values to determine the maximum value of.
selector
Type: System..::.Func<(Of <(TSource, TResult>)>)
A transform function to apply to each element.

Type Parameters

TSource
The type of elements of source.
TResult
The type of the value returned by selector.

Return Value

The maximum value in the sequence.

Exceptions

Exception | Condition
System..::.ArgumentNullException | source or selector is a null reference (Nothing in Visual Basic).
System..::.InvalidOperationException | source contains no elements and TResult is a non-nullable value type.
System..::.AggregateException | One or more exceptions occurred during the evaluation of the query.
System..::.OperationCanceledException | The query was canceled.

See Also

ParallelEnumerable Class
Max Overload
System.Linq Namespace


Min Method

[image] [image]

.NET Framework Class Library
ParallelEnumerable..::.Min Method
ParallelEnumerable Class See Also Send Feedback

Overload List

Name | Description
Min(ParallelQuery<(Of <(Decimal>)>)) | Returns the minimum value in a parallel sequence of values.
Min(ParallelQuery<(Of <(Double>)>)) | Returns the minimum value in a parallel sequence of values.
Min(ParallelQuery<(Of <(Int32>)>)) | Returns the minimum value in a parallel sequence of values.
Min(ParallelQuery<(Of <(Int64>)>)) | Returns the minimum value in a parallel sequence of values.
Min(ParallelQuery<(Of <(Nullable<(Of <(Decimal>)>)>)>)) | Returns the minimum value in a parallel sequence of values.
Min(ParallelQuery<(Of <(Nullable<(Of <(Double>)>)>)>)) | Returns the minimum value in a parallel sequence of values.
Min(ParallelQuery<(Of <(Nullable<(Of <(Int32>)>)>)>)) | Returns the minimum value in a parallel sequence of values.
Min(ParallelQuery<(Of <(Nullable<(Of <(Int64>)>)>)>)) | Returns the minimum value in a parallel sequence of values.
Min(ParallelQuery<(Of <(Nullable<(Of <(Single>)>)>)>)) | Returns the minimum value in a parallel sequence of values.
Min(ParallelQuery<(Of <(Single>)>)) | Returns the minimum value in a parallel sequence of values.
Min<(Of <(TSource>)>)(ParallelQuery<(Of <(TSource>)>)) | Returns the minimum value in a parallel sequence of values.
Min<(Of <(TSource>)>)(ParallelQuery<(Of <(TSource>)>), Func<(Of <(TSource, Decimal>)>)) | Invokes in parallel a transform function on each element of a sequence and returns the minimum value.
Min<(Of <(TSource>)>)(ParallelQuery<(Of <(TSource>)>), Func<(Of <(TSource, Double>)>)) | Invokes in parallel a transform function on each element of a sequence and returns the minimum value.
Min<(Of <(TSource>)>)(ParallelQuery<(Of <(TSource>)>), Func<(Of <(TSource, Int32>)>)) | Invokes in parallel a transform function on each element of a sequence and returns the minimum value.
Min<(Of <(TSource>)>)(ParallelQuery<(Of <(TSource>)>), Func<(Of <(TSource, Int64>)>)) | Invokes in parallel a transform function on each element of a sequence and returns the minimum value.
Min<(Of <(TSource>)>)(ParallelQuery<(Of <(TSource>)>), Func<(Of <(TSource, Nullable<(Of <(Decimal>)>)>)>)) | Invokes in parallel a transform function on each element of a sequence and returns the minimum value.
Min<(Of <(TSource>)>)(ParallelQuery<(Of <(TSource>)>), Func<(Of <(TSource, Nullable<(Of <(Double>)>)>)>)) | Invokes in parallel a transform function on each element of a sequence and returns the minimum value.
Min<(Of <(TSource>)>)(ParallelQuery<(Of <(TSource>)>), Func<(Of <(TSource, Nullable<(Of <(Int32>)>)>)>)) | Invokes in parallel a transform function on each element of a sequence and returns the minimum value.
Min<(Of <(TSource>)>)(ParallelQuery<(Of <(TSource>)>), Func<(Of <(TSource, Nullable<(Of <(Int64>)>)>)>)) | Invokes in parallel a transform function on each element of a sequence and returns the minimum value.
Min<(Of <(TSource>)>)(ParallelQuery<(Of <(TSource>)>), Func<(Of <(TSource, Nullable<(Of <(Single>)>)>)>)) | Invokes in parallel a transform function on each element of a sequence and returns the minimum value.
Min<(Of <(TSource>)>)(ParallelQuery<(Of <(TSource>)>), Func<(Of <(TSource, Single>)>)) | Invokes in parallel a transform function on each element of a sequence and returns the minimum value.
Min<(Of <(TSource, TResult>)>)(ParallelQuery<(Of <(TSource>)>), Func<(Of <(TSource, TResult>)>)) | Invokes in parallel a transform function on each element of a sequence and returns the minimum value.

See Also

ParallelEnumerable Class
System.Linq Namespace


Min Method (ParallelQuery(Decimal))

[image]

.NET Framework Class Library
ParallelEnumerable..::.Min Method (ParallelQuery<(Of <(Decimal>)>))
ParallelEnumerable Class See Also Send Feedback

Returns the minimum value in a parallel sequence of values.

Namespace: System.Linq
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function Min ( _
    source As ParallelQuery(Of Decimal) _
) As Decimal
C#
public static decimal Min(
    ParallelQuery<decimal> source
)

Parameters

source
Type: System.Linq..::.ParallelQuery <(Of <(Decimal>)>)
A sequence of values to determine the minimum value of.

Return Value

The minimum value in the sequence.

Exceptions

Exception | Condition
System..::.ArgumentNullException | source is a null reference (Nothing in Visual Basic).
System..::.InvalidOperationException | source contains no elements.
System..::.AggregateException | One or more exceptions occurred during the evaluation of the query.
System..::.OperationCanceledException | The query was canceled.

See Also

ParallelEnumerable Class
Min Overload
System.Linq Namespace


Min Method (ParallelQuery(Double))

[image]

.NET Framework Class Library
ParallelEnumerable..::.Min Method (ParallelQuery<(Of <(Double>)>))
ParallelEnumerable Class See Also Send Feedback

Returns the minimum value in a parallel sequence of values.

Namespace: System.Linq
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function Min ( _
    source As ParallelQuery(Of Double) _
) As Double
C#
public static double Min(
    ParallelQuery<double> source
)

Parameters

source
Type: System.Linq..::.ParallelQuery <(Of <(Double>)>)
A sequence of values to determine the minimum value of.

Return Value

The minimum value in the sequence.

Exceptions

Exception | Condition
System..::.ArgumentNullException | source is a null reference (Nothing in Visual Basic).
System..::.InvalidOperationException | source contains no elements.
System..::.AggregateException | One or more exceptions occurred during the evaluation of the query.
System..::.OperationCanceledException | The query was canceled.

See Also

ParallelEnumerable Class
Min Overload
System.Linq Namespace


Min Method (ParallelQuery(Int32))

[image]

.NET Framework Class Library
ParallelEnumerable..::.Min Method (ParallelQuery<(Of <(Int32>)>))
ParallelEnumerable Class See Also Send Feedback

Returns the minimum value in a parallel sequence of values.

Namespace: System.Linq
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function Min ( _
    source As ParallelQuery(Of Integer) _
) As Integer
C#
public static int Min(
    ParallelQuery<int> source
)

Parameters

source
Type: System.Linq..::.ParallelQuery <(Of <(Int32>)>)
A sequence of values to determine the minimum value of.

Return Value

The minimum value in the sequence.

Exceptions

Exception | Condition
System..::.ArgumentNullException | source is a null reference (Nothing in Visual Basic).
System..::.InvalidOperationException | source contains no elements.
System..::.AggregateException | One or more exceptions occurred during the evaluation of the query.
System..::.OperationCanceledException | The query was canceled.

See Also

ParallelEnumerable Class
Min Overload
System.Linq Namespace


Min Method (ParallelQuery(Int64))

[image]

.NET Framework Class Library
ParallelEnumerable..::.Min Method (ParallelQuery<(Of <(Int64>)>))
ParallelEnumerable Class See Also Send Feedback

Returns the minimum value in a parallel sequence of values.

Namespace: System.Linq
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function Min ( _
    source As ParallelQuery(Of Long) _
) As Long
C#
public static long Min(
    ParallelQuery<long> source
)

Parameters

source
Type: System.Linq..::.ParallelQuery <(Of <(Int64>)>)
A sequence of values to determine the minimum value of.

Return Value

The minimum value in the sequence.

Exceptions

Exception | Condition
System..::.ArgumentNullException | source is a null reference (Nothing in Visual Basic).
System..::.InvalidOperationException | source contains no elements.
System..::.AggregateException | One or more exceptions occurred during the evaluation of the query.
System..::.OperationCanceledException | The query was canceled.

See Also

ParallelEnumerable Class
Min Overload
System.Linq Namespace


Min Method (ParallelQuery(Nullable(Decimal)))

[image]

.NET Framework Class Library
ParallelEnumerable..::.Min Method (ParallelQuery<(Of <(Nullable<(Of <(Decimal>)>)>)>))
ParallelEnumerable Class See Also Send Feedback

Returns the minimum value in a parallel sequence of values.

Namespace: System.Linq
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function Min ( _
    source As ParallelQuery(Of Nullable(Of Decimal)) _
) As Nullable(Of Decimal)
C#
public static Nullable<decimal> Min(
    ParallelQuery<Nullable<decimal>> source
)

Parameters

source
Type: System.Linq..::.ParallelQuery <(Of <(Nullable<(Of <(Decimal>)>)>)>)
A sequence of values to determine the minimum value of.

Return Value

The minimum value in the sequence.

Exceptions

Exception | Condition
System..::.ArgumentNullException | source is a null reference (Nothing in Visual Basic).
System..::.AggregateException | One or more exceptions occurred during the evaluation of the query.
System..::.OperationCanceledException | The query was canceled.

See Also

ParallelEnumerable Class
Min Overload
System.Linq Namespace


Min Method (ParallelQuery(Nullable(Double)))

[image]

.NET Framework Class Library
ParallelEnumerable..::.Min Method (ParallelQuery<(Of <(Nullable<(Of <(Double>)>)>)>))
ParallelEnumerable Class See Also Send Feedback

Returns the minimum value in a parallel sequence of values.

Namespace: System.Linq
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function Min ( _
    source As ParallelQuery(Of Nullable(Of Double)) _
) As Nullable(Of Double)
C#
public static Nullable<double> Min(
    ParallelQuery<Nullable<double>> source
)

Parameters

source
Type: System.Linq..::.ParallelQuery <(Of <(Nullable<(Of <(Double>)>)>)>)
A sequence of values to determine the minimum value of.

Return Value

The minimum value in the sequence.

Exceptions

Exception | Condition
System..::.ArgumentNullException | source is a null reference (Nothing in Visual Basic).
System..::.AggregateException | One or more exceptions occurred during the evaluation of the query.
System..::.OperationCanceledException | The query was canceled.

See Also

ParallelEnumerable Class
Min Overload
System.Linq Namespace


Min Method (ParallelQuery(Nullable(Int32)))

[image]

.NET Framework Class Library
ParallelEnumerable..::.Min Method (ParallelQuery<(Of <(Nullable<(Of <(Int32>)>)>)>))
ParallelEnumerable Class See Also Send Feedback

Returns the minimum value in a parallel sequence of values.

Namespace: System.Linq
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function Min ( _
    source As ParallelQuery(Of Nullable(Of Integer)) _
) As Nullable(Of Integer)
C#
public static Nullable<int> Min(
    ParallelQuery<Nullable<int>> source
)

Parameters

source
Type: System.Linq..::.ParallelQuery <(Of <(Nullable<(Of <(Int32>)>)>)>)
A sequence of values to determine the minimum value of.

Return Value

The minimum value in the sequence.

Exceptions

Exception | Condition
System..::.ArgumentNullException | source is a null reference (Nothing in Visual Basic).
System..::.AggregateException | One or more exceptions occurred during the evaluation of the query.
System..::.OperationCanceledException | The query was canceled.

See Also

ParallelEnumerable Class
Min Overload
System.Linq Namespace


Min Method (ParallelQuery(Nullable(Int64)))

[image]

.NET Framework Class Library
ParallelEnumerable..::.Min Method (ParallelQuery<(Of <(Nullable<(Of <(Int64>)>)>)>))
ParallelEnumerable Class See Also Send Feedback

Returns the minimum value in a parallel sequence of values.

Namespace: System.Linq
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function Min ( _
    source As ParallelQuery(Of Nullable(Of Long)) _
) As Nullable(Of Long)
C#
public static Nullable<long> Min(
    ParallelQuery<Nullable<long>> source
)

Parameters

source
Type: System.Linq..::.ParallelQuery <(Of <(Nullable<(Of <(Int64>)>)>)>)
A sequence of values to determine the minimum value of.

Return Value

The minimum value in the sequence.

Exceptions

Exception | Condition
System..::.ArgumentNullException | source is a null reference (Nothing in Visual Basic).
System..::.AggregateException | One or more exceptions occurred during the evaluation of the query.
System..::.OperationCanceledException | The query was canceled.

See Also

ParallelEnumerable Class
Min Overload
System.Linq Namespace


Min Method (ParallelQuery(Nullable(Single)))

[image]

.NET Framework Class Library
ParallelEnumerable..::.Min Method (ParallelQuery<(Of <(Nullable<(Of <(Single>)>)>)>))
ParallelEnumerable Class See Also Send Feedback

Returns the minimum value in a parallel sequence of values.

Namespace: System.Linq
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function Min ( _
    source As ParallelQuery(Of Nullable(Of Single)) _
) As Nullable(Of Single)
C#
public static Nullable<float> Min(
    ParallelQuery<Nullable<float>> source
)

Parameters

source
Type: System.Linq..::.ParallelQuery <(Of <(Nullable<(Of <(Single>)>)>)>)
A sequence of values to determine the minimum value of.

Return Value

The minimum value in the sequence.

Exceptions

Exception | Condition
System..::.ArgumentNullException | source is a null reference (Nothing in Visual Basic).
System..::.AggregateException | One or more exceptions occurred during the evaluation of the query.
System..::.OperationCanceledException | The query was canceled.

See Also

ParallelEnumerable Class
Min Overload
System.Linq Namespace


Min Method (ParallelQuery(Single))

[image]

.NET Framework Class Library
ParallelEnumerable..::.Min Method (ParallelQuery<(Of <(Single>)>))
ParallelEnumerable Class See Also Send Feedback

Returns the minimum value in a parallel sequence of values.

Namespace: System.Linq
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function Min ( _
    source As ParallelQuery(Of Single) _
) As Single
C#
public static float Min(
    ParallelQuery<float> source
)

Parameters

source
Type: System.Linq..::.ParallelQuery <(Of <(Single>)>)
A sequence of values to determine the minimum value of.

Return Value

The minimum value in the sequence.

Exceptions

Exception | Condition
System..::.ArgumentNullException | source is a null reference (Nothing in Visual Basic).
System..::.InvalidOperationException | source contains no elements.
System..::.AggregateException | One or more exceptions occurred during the evaluation of the query.
System..::.OperationCanceledException | The query was canceled.

See Also

ParallelEnumerable Class
Min Overload
System.Linq Namespace


Min(TSource) Method (ParallelQuery(TSource))

[image]

.NET Framework Class Library
ParallelEnumerable..::.Min<(Of <(TSource>)>) Method (ParallelQuery<(Of <(TSource>)>))
ParallelEnumerable Class See Also Send Feedback

Returns the minimum value in a parallel sequence of values.

Namespace: System.Linq
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function Min(Of TSource) ( _
    source As ParallelQuery(Of TSource) _
) As TSource
C#
public static TSource Min<TSource>(
    ParallelQuery<TSource> source
)

Parameters

source
Type: System.Linq..::.ParallelQuery <(Of <(TSource>)>)
A sequence of values to determine the minimum value of.

Type Parameters

TSource
The type of elements of source.

Return Value

The minimum value in the sequence.

Exceptions

Exception | Condition
System..::.ArgumentNullException | source is a null reference (Nothing in Visual Basic).
System..::.InvalidOperationException | source contains no elements and TSource is a non-nullable value type.
System..::.AggregateException | One or more exceptions occurred during the evaluation of the query.
System..::.OperationCanceledException | The query was canceled.

See Also

ParallelEnumerable Class
Min Overload
System.Linq Namespace


Min(TSource) Method (ParallelQuery(TSource), Func(TSource, Decimal))

[image]

.NET Framework Class Library
ParallelEnumerable..::.Min<(Of <(TSource>)>) Method (ParallelQuery<(Of <(TSource>)>), Func<(Of <(TSource, Decimal>)>))
ParallelEnumerable Class See Also Send Feedback

Invokes in parallel a transform function on each element of a sequence and returns the minimum value.

Namespace: System.Linq
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function Min(Of TSource) ( _
    source As ParallelQuery(Of TSource), _
    selector As Func(Of TSource, Decimal) _
) As Decimal
C#
public static decimal Min<TSource>(
    ParallelQuery<TSource> source,
    Func<TSource, decimal> selector
)

Parameters

source
Type: System.Linq..::.ParallelQuery <(Of <(TSource>)>)
A sequence of values to determine the minimum value of.
selector
Type: System..::.Func<(Of <(TSource, Decimal>)>)
A transform function to apply to each element.

Type Parameters

TSource
The type of elements of source.

Return Value

The minimum value in the sequence.

Exceptions

Exception | Condition
System..::.ArgumentNullException | source or selector is a null reference (Nothing in Visual Basic).
System..::.InvalidOperationException | source contains no elements.
System..::.AggregateException | One or more exceptions occurred during the evaluation of the query.
System..::.OperationCanceledException | The query was canceled.

See Also

ParallelEnumerable Class
Min Overload
System.Linq Namespace


Min(TSource) Method (ParallelQuery(TSource), Func(TSource, Double))

[image]

.NET Framework Class Library
ParallelEnumerable..::.Min<(Of <(TSource>)>) Method (ParallelQuery<(Of <(TSource>)>), Func<(Of <(TSource, Double>)>))
ParallelEnumerable Class See Also Send Feedback

Invokes in parallel a transform function on each element of a sequence and returns the minimum value.

Namespace: System.Linq
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function Min(Of TSource) ( _
    source As ParallelQuery(Of TSource), _
    selector As Func(Of TSource, Double) _
) As Double
C#
public static double Min<TSource>(
    ParallelQuery<TSource> source,
    Func<TSource, double> selector
)

Parameters

source
Type: System.Linq..::.ParallelQuery <(Of <(TSource>)>)
A sequence of values to determine the minimum value of.
selector
Type: System..::.Func<(Of <(TSource, Double>)>)
A transform function to apply to each element.

Type Parameters

TSource
The type of elements of source.

Return Value

The minimum value in the sequence.

Exceptions

Exception | Condition
System..::.ArgumentNullException | source or selector is a null reference (Nothing in Visual Basic).
System..::.InvalidOperationException | source contains no elements.
System..::.AggregateException | One or more exceptions occurred during the evaluation of the query.
System..::.OperationCanceledException | The query was canceled.

See Also

ParallelEnumerable Class
Min Overload
System.Linq Namespace


Min(TSource) Method (ParallelQuery(TSource), Func(TSource, Int32))

[image]

.NET Framework Class Library
ParallelEnumerable..::.Min<(Of <(TSource>)>) Method (ParallelQuery<(Of <(TSource>)>), Func<(Of <(TSource, Int32>)>))
ParallelEnumerable Class See Also Send Feedback

Invokes in parallel a transform function on each element of a sequence and returns the minimum value.

Namespace: System.Linq
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function Min(Of TSource) ( _
    source As ParallelQuery(Of TSource), _
    selector As Func(Of TSource, Integer) _
) As Integer
C#
public static int Min<TSource>(
    ParallelQuery<TSource> source,
    Func<TSource, int> selector
)

Parameters

source
Type: System.Linq..::.ParallelQuery <(Of <(TSource>)>)
A sequence of values to determine the minimum value of.
selector
Type: System..::.Func<(Of <(TSource, Int32>)>)
A transform function to apply to each element.

Type Parameters

TSource
The type of elements of source.

Return Value

The minimum value in the sequence.

Exceptions

Exception | Condition
System..::.ArgumentNullException | source or selector is a null reference (Nothing in Visual Basic).
System..::.InvalidOperationException | source contains no elements.
System..::.AggregateException | One or more exceptions occurred during the evaluation of the query.
System..::.OperationCanceledException | The query was canceled.

See Also

ParallelEnumerable Class
Min Overload
System.Linq Namespace


Min(TSource) Method (ParallelQuery(TSource), Func(TSource, Int64))

[image]

.NET Framework Class Library
ParallelEnumerable..::.Min<(Of <(TSource>)>) Method (ParallelQuery<(Of <(TSource>)>), Func<(Of <(TSource, Int64>)>))
ParallelEnumerable Class See Also Send Feedback

Invokes in parallel a transform function on each element of a sequence and returns the minimum value.

Namespace: System.Linq
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function Min(Of TSource) ( _
    source As ParallelQuery(Of TSource), _
    selector As Func(Of TSource, Long) _
) As Long
C#
public static long Min<TSource>(
    ParallelQuery<TSource> source,
    Func<TSource, long> selector
)

Parameters

source
Type: System.Linq..::.ParallelQuery <(Of <(TSource>)>)
A sequence of values to determine the minimum value of.
selector
Type: System..::.Func<(Of <(TSource, Int64>)>)
A transform function to apply to each element.

Type Parameters

TSource
The type of elements of source.

Return Value

The minimum value in the sequence.

Exceptions

Exception | Condition
System..::.ArgumentNullException | source or selector is a null reference (Nothing in Visual Basic).
System..::.InvalidOperationException | source contains no elements.
System..::.AggregateException | One or more exceptions occurred during the evaluation of the query.
System..::.OperationCanceledException | The query was canceled.

See Also

ParallelEnumerable Class
Min Overload
System.Linq Namespace


Min(TSource) Method (ParallelQuery(TSource), Func(TSource, Nullable(Decimal)))

[image]

.NET Framework Class Library
ParallelEnumerable..::.Min<(Of <(TSource>)>) Method (ParallelQuery<(Of <(TSource>)>), Func<(Of <(TSource, Nullable<(Of <(Decimal>)>)>)>))
ParallelEnumerable Class See Also Send Feedback

Invokes in parallel a transform function on each element of a sequence and returns the minimum value.

Namespace: System.Linq
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function Min(Of TSource) ( _
    source As ParallelQuery(Of TSource), _
    selector As Func(Of TSource, Nullable(Of Decimal)) _
) As Nullable(Of Decimal)
C#
public static Nullable<decimal> Min<TSource>(
    ParallelQuery<TSource> source,
    Func<TSource, Nullable<decimal>> selector
)

Parameters

source
Type: System.Linq..::.ParallelQuery <(Of <(TSource>)>)
A sequence of values to determine the minimum value of.
selector
Type: System..::.Func<(Of <(TSource, Nullable<(Of <(Decimal>)>)>)>)
A transform function to apply to each element.

Type Parameters

TSource
The type of elements of source.

Return Value

The minimum value in the sequence.

Exceptions

Exception | Condition
System..::.ArgumentNullException | source or selector is a null reference (Nothing in Visual Basic).
System..::.AggregateException | One or more exceptions occurred during the evaluation of the query.
System..::.OperationCanceledException | The query was canceled.

See Also

ParallelEnumerable Class
Min Overload
System.Linq Namespace


Min(TSource) Method (ParallelQuery(TSource), Func(TSource, Nullable(Double)))

[image]

.NET Framework Class Library
ParallelEnumerable..::.Min<(Of <(TSource>)>) Method (ParallelQuery<(Of <(TSource>)>), Func<(Of <(TSource, Nullable<(Of <(Double>)>)>)>))
ParallelEnumerable Class See Also Send Feedback

Invokes in parallel a transform function on each element of a sequence and returns the minimum value.

Namespace: System.Linq
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function Min(Of TSource) ( _
    source As ParallelQuery(Of TSource), _
    selector As Func(Of TSource, Nullable(Of Double)) _
) As Nullable(Of Double)
C#
public static Nullable<double> Min<TSource>(
    ParallelQuery<TSource> source,
    Func<TSource, Nullable<double>> selector
)

Parameters

source
Type: System.Linq..::.ParallelQuery <(Of <(TSource>)>)
A sequence of values to determine the minimum value of.
selector
Type: System..::.Func<(Of <(TSource, Nullable<(Of <(Double>)>)>)>)
A transform function to apply to each element.

Type Parameters

TSource
The type of elements of source.

Return Value

The minimum value in the sequence.

Exceptions

Exception | Condition
System..::.ArgumentNullException | source or selector is a null reference (Nothing in Visual Basic).
System..::.AggregateException | One or more exceptions occurred during the evaluation of the query.
System..::.OperationCanceledException | The query was canceled.

See Also

ParallelEnumerable Class
Min Overload
System.Linq Namespace


Min(TSource) Method (ParallelQuery(TSource), Func(TSource, Nullable(Int32)))

[image]

.NET Framework Class Library
ParallelEnumerable..::.Min<(Of <(TSource>)>) Method (ParallelQuery<(Of <(TSource>)>), Func<(Of <(TSource, Nullable<(Of <(Int32>)>)>)>))
ParallelEnumerable Class See Also Send Feedback

Invokes in parallel a transform function on each element of a sequence and returns the minimum value.

Namespace: System.Linq
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function Min(Of TSource) ( _
    source As ParallelQuery(Of TSource), _
    selector As Func(Of TSource, Nullable(Of Integer)) _
) As Nullable(Of Integer)
C#
public static Nullable<int> Min<TSource>(
    ParallelQuery<TSource> source,
    Func<TSource, Nullable<int>> selector
)

Parameters

source
Type: System.Linq..::.ParallelQuery <(Of <(TSource>)>)
A sequence of values to determine the minimum value of.
selector
Type: System..::.Func<(Of <(TSource, Nullable<(Of <(Int32>)>)>)>)
A transform function to apply to each element.

Type Parameters

TSource
The type of elements of source.

Return Value

The minimum value in the sequence.

Exceptions

Exception | Condition
System..::.ArgumentNullException | source or selector is a null reference (Nothing in Visual Basic).
System..::.AggregateException | One or more exceptions occurred during the evaluation of the query.
System..::.OperationCanceledException | The query was canceled.

See Also

ParallelEnumerable Class
Min Overload
System.Linq Namespace


Min(TSource) Method (ParallelQuery(TSource), Func(TSource, Nullable(Int64)))

[image]

.NET Framework Class Library
ParallelEnumerable..::.Min<(Of <(TSource>)>) Method (ParallelQuery<(Of <(TSource>)>), Func<(Of <(TSource, Nullable<(Of <(Int64>)>)>)>))
ParallelEnumerable Class See Also Send Feedback

Invokes in parallel a transform function on each element of a sequence and returns the minimum value.

Namespace: System.Linq
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function Min(Of TSource) ( _
    source As ParallelQuery(Of TSource), _
    selector As Func(Of TSource, Nullable(Of Long)) _
) As Nullable(Of Long)
C#
public static Nullable<long> Min<TSource>(
    ParallelQuery<TSource> source,
    Func<TSource, Nullable<long>> selector
)

Parameters

source
Type: System.Linq..::.ParallelQuery <(Of <(TSource>)>)
A sequence of values to determine the minimum value of.
selector
Type: System..::.Func<(Of <(TSource, Nullable<(Of <(Int64>)>)>)>)
A transform function to apply to each element.

Type Parameters

TSource
The type of elements of source.

Return Value

The minimum value in the sequence.

Exceptions

Exception | Condition
System..::.ArgumentNullException | source or selector is a null reference (Nothing in Visual Basic).
System..::.AggregateException | One or more exceptions occurred during the evaluation of the query.
System..::.OperationCanceledException | The query was canceled.

See Also

ParallelEnumerable Class
Min Overload
System.Linq Namespace


Min(TSource) Method (ParallelQuery(TSource), Func(TSource, Nullable(Single)))

[image]

.NET Framework Class Library
ParallelEnumerable..::.Min<(Of <(TSource>)>) Method (ParallelQuery<(Of <(TSource>)>), Func<(Of <(TSource, Nullable<(Of <(Single>)>)>)>))
ParallelEnumerable Class See Also Send Feedback

Invokes in parallel a transform function on each element of a sequence and returns the minimum value.

Namespace: System.Linq
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function Min(Of TSource) ( _
    source As ParallelQuery(Of TSource), _
    selector As Func(Of TSource, Nullable(Of Single)) _
) As Nullable(Of Single)
C#
public static Nullable<float> Min<TSource>(
    ParallelQuery<TSource> source,
    Func<TSource, Nullable<float>> selector
)

Parameters

source
Type: System.Linq..::.ParallelQuery <(Of <(TSource>)>)
A sequence of values to determine the minimum value of.
selector
Type: System..::.Func<(Of <(TSource, Nullable<(Of <(Single>)>)>)>)
A transform function to apply to each element.

Type Parameters

TSource
The type of elements of source.

Return Value

The minimum value in the sequence.

Exceptions

Exception | Condition
System..::.ArgumentNullException | source or selector is a null reference (Nothing in Visual Basic).
System..::.AggregateException | One or more exceptions occurred during the evaluation of the query.
System..::.OperationCanceledException | The query was canceled.

See Also

ParallelEnumerable Class
Min Overload
System.Linq Namespace


Min(TSource) Method (ParallelQuery(TSource), Func(TSource, Single))

[image]

.NET Framework Class Library
ParallelEnumerable..::.Min<(Of <(TSource>)>) Method (ParallelQuery<(Of <(TSource>)>), Func<(Of <(TSource, Single>)>))
ParallelEnumerable Class See Also Send Feedback

Invokes in parallel a transform function on each element of a sequence and returns the minimum value.

Namespace: System.Linq
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function Min(Of TSource) ( _
    source As ParallelQuery(Of TSource), _
    selector As Func(Of TSource, Single) _
) As Single
C#
public static float Min<TSource>(
    ParallelQuery<TSource> source,
    Func<TSource, float> selector
)

Parameters

source
Type: System.Linq..::.ParallelQuery <(Of <(TSource>)>)
A sequence of values to determine the minimum value of.
selector
Type: System..::.Func<(Of <(TSource, Single>)>)
A transform function to apply to each element.

Type Parameters

TSource
The type of elements of source.

Return Value

The minimum value in the sequence.

Exceptions

Exception | Condition
System..::.ArgumentNullException | source or selector is a null reference (Nothing in Visual Basic).
System..::.InvalidOperationException | source contains no elements.
System..::.AggregateException | One or more exceptions occurred during the evaluation of the query.
System..::.OperationCanceledException | The query was canceled.

See Also

ParallelEnumerable Class
Min Overload
System.Linq Namespace


Min(TSource, TResult) Method (ParallelQuery(TSource), Func(TSource, TResult))

[image]

.NET Framework Class Library
ParallelEnumerable..::.Min<(Of <(TSource, TResult>)>) Method (ParallelQuery<(Of <(TSource>)>), Func<(Of <(TSource, TResult>)>))
ParallelEnumerable Class See Also Send Feedback

Invokes in parallel a transform function on each element of a sequence and returns the minimum value.

Namespace: System.Linq
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function Min(Of TSource, TResult) ( _
    source As ParallelQuery(Of TSource), _
    selector As Func(Of TSource, TResult) _
) As TResult
C#
public static TResult Min<TSource, TResult>(
    ParallelQuery<TSource> source,
    Func<TSource, TResult> selector
)

Parameters

source
Type: System.Linq..::.ParallelQuery <(Of <(TSource>)>)
A sequence of values to determine the minimum value of.
selector
Type: System..::.Func<(Of <(TSource, TResult>)>)
A transform function to apply to each element.

Type Parameters

TSource
The type of elements of source.
TResult
The type of the value returned by selector.

Return Value

The minimum value in the sequence.

Exceptions

Exception | Condition
System..::.ArgumentNullException | source or selector is a null reference (Nothing in Visual Basic).
System..::.InvalidOperationException | source contains no elements and TResult is a non-nullable value type.
System..::.AggregateException | One or more exceptions occurred during the evaluation of the query.
System..::.OperationCanceledException | The query was canceled.

See Also

ParallelEnumerable Class
Min Overload
System.Linq Namespace


OfType(TResult) Method

[image]

.NET Framework Class Library
ParallelEnumerable..::.OfType<(Of <(TResult>)>) Method
ParallelEnumerable Class See Also Send Feedback

Filters the elements of a ParallelQuery based on a specified type.

Namespace: System.Linq
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function OfType(Of TResult) ( _
    source As ParallelQuery _
) As ParallelQuery(Of TResult)
C#
public static ParallelQuery<TResult> OfType<TResult>(
    ParallelQuery source
)

Parameters

source
Type: System.Linq..::.ParallelQuery
The sequence whose elements to filter.

Type Parameters

TResult
The type to filter the elements of the sequence on.

Return Value

A sequence that contains elements from the input sequence of type TResult.

Exceptions

Exception | Condition
System..::.ArgumentNullException | source is a null reference (Nothing in Visual Basic).

See Also

ParallelEnumerable Class
System.Linq Namespace


OrderBy Method

[image] [image]

.NET Framework Class Library
ParallelEnumerable..::.OrderBy Method
ParallelEnumerable Class See Also Send Feedback

Overload List

Name | Description
OrderBy<(Of <(TSource, TKey>)>)(ParallelQuery<(Of <(TSource>)>), Func<(Of <(TSource, TKey>)>)) | Sorts in parallel the elements of a sequence in ascending order according to a key.
OrderBy<(Of <(TSource, TKey>)>)(ParallelQuery<(Of <(TSource>)>), Func<(Of <(TSource, TKey>)>), IComparer<(Of <(TKey>)>)) | Sorts in parallel the elements of a sequence in ascending order by using a specified comparer.

See Also

ParallelEnumerable Class
System.Linq Namespace


OrderBy(TSource, TKey) Method (ParallelQuery(TSource), Func(TSource, TKey))

[image]

.NET Framework Class Library
ParallelEnumerable..::.OrderBy<(Of <(TSource, TKey>)>) Method (ParallelQuery<(Of <(TSource>)>), Func<(Of <(TSource, TKey>)>))
ParallelEnumerable Class See Also Send Feedback

Sorts in parallel the elements of a sequence in ascending order according to a key.

Namespace: System.Linq
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function OrderBy(Of TSource, TKey) ( _
    source As ParallelQuery(Of TSource), _
    keySelector As Func(Of TSource, TKey) _
) As OrderedParallelQuery(Of TSource)
C#
public static OrderedParallelQuery<TSource> OrderBy<TSource, TKey>(
    ParallelQuery<TSource> source,
    Func<TSource, TKey> keySelector
)

Parameters

source
Type: System.Linq..::.ParallelQuery <(Of <(TSource>)>)
A sequence of values to order.
keySelector
Type: System..::.Func<(Of <(TSource, TKey>)>)
A function to extract a key from an element.

Type Parameters

TSource
The type of elements of source.
TKey
The type of the key returned by keySelector.

Return Value

An OrderedParallelQuery{TSource} whose elements are sorted according to a key.

Remarks

In contrast to the sequential implementation, this is not a stable sort. To achieve a stable sort, change a query of the form:
Copy Code
var ordered = source.OrderBy((e) => e.k);
to instead be formed as:
Copy Code
var ordered = source.Select((e,i) => new { E=e, I=i }).OrderBy((v) => v.i).Select((v) => v.e);

Exceptions

Exception | Condition
System..::.ArgumentNullException | source or keySelector is a null reference (Nothing in Visual Basic).

See Also

ParallelEnumerable Class
OrderBy Overload
System.Linq Namespace


OrderBy(TSource, TKey) Method (ParallelQuery(TSource), Func(TSource, TKey), IComparer(TKey))

[image]

.NET Framework Class Library
ParallelEnumerable..::.OrderBy<(Of <(TSource, TKey>)>) Method (ParallelQuery<(Of <(TSource>)>), Func<(Of <(TSource, TKey>)>), IComparer<(Of <(TKey>)>))
ParallelEnumerable Class See Also Send Feedback

Sorts in parallel the elements of a sequence in ascending order by using a specified comparer.

Namespace: System.Linq
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function OrderBy(Of TSource, TKey) ( _
    source As ParallelQuery(Of TSource), _
    keySelector As Func(Of TSource, TKey), _
    comparer As IComparer(Of TKey) _
) As OrderedParallelQuery(Of TSource)
C#
public static OrderedParallelQuery<TSource> OrderBy<TSource, TKey>(
    ParallelQuery<TSource> source,
    Func<TSource, TKey> keySelector,
    IComparer<TKey> comparer
)

Parameters

source
Type: System.Linq..::.ParallelQuery <(Of <(TSource>)>)
A sequence of values to order.
keySelector
Type: System..::.Func<(Of <(TSource, TKey>)>)
A function to extract a key from an element.
comparer
Type: System.Collections.Generic..::.IComparer<(Of <(TKey>)>)
An IComparer{TKey} to compare keys.

Type Parameters

TSource
The type of elements of source.
TKey
The type of the key returned by keySelector.

Return Value

An OrderedParallelQuery{TSource} whose elements are sorted according to a key.

Remarks

In contrast to the sequential implementation, this is not a stable sort. See the remarks for OrderBy(ParallelQuery{TSource}, Func{TSource,TKey}) for an approach to implementing a stable sort.

Exceptions

Exception | Condition
System..::.ArgumentNullException | source or keySelector is a null reference (Nothing in Visual Basic).

See Also

ParallelEnumerable Class
OrderBy Overload
System.Linq Namespace


OrderByDescending Method

[image] [image]

.NET Framework Class Library
ParallelEnumerable..::.OrderByDescending Method
ParallelEnumerable Class See Also Send Feedback

Overload List

Name | Description
OrderByDescending<(Of <(TSource, TKey>)>)(ParallelQuery<(Of <(TSource>)>), Func<(Of <(TSource, TKey>)>)) | Sorts in parallel the elements of a sequence in descending order according to a key.
OrderByDescending<(Of <(TSource, TKey>)>)(ParallelQuery<(Of <(TSource>)>), Func<(Of <(TSource, TKey>)>), IComparer<(Of <(TKey>)>)) | Sorts the elements of a sequence in descending order by using a specified comparer.

See Also

ParallelEnumerable Class
System.Linq Namespace


OrderByDescending(TSource, TKey) Method (ParallelQuery(TSource), Func(TSource, TKey))

[image]

.NET Framework Class Library
ParallelEnumerable..::.OrderByDescending<(Of <(TSource, TKey>)>) Method (ParallelQuery<(Of <(TSource>)>), Func<(Of <(TSource, TKey>)>))
ParallelEnumerable Class See Also Send Feedback

Sorts in parallel the elements of a sequence in descending order according to a key.

Namespace: System.Linq
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function OrderByDescending(Of TSource, TKey) ( _
    source As ParallelQuery(Of TSource), _
    keySelector As Func(Of TSource, TKey) _
) As OrderedParallelQuery(Of TSource)
C#
public static OrderedParallelQuery<TSource> OrderByDescending<TSource, TKey>(
    ParallelQuery<TSource> source,
    Func<TSource, TKey> keySelector
)

Parameters

source
Type: System.Linq..::.ParallelQuery <(Of <(TSource>)>)
A sequence of values to order.
keySelector
Type: System..::.Func<(Of <(TSource, TKey>)>)
A function to extract a key from an element.

Type Parameters

TSource
The type of elements of source.
TKey
The type of the key returned by keySelector.

Return Value

An OrderedParallelQuery{TSource} whose elements are sorted descending according to a key.

Remarks

In contrast to the sequential implementation, this is not a stable sort. See the remarks for OrderBy(ParallelQuery{TSource}, Func{TSource,TKey}) for an approach to implementing a stable sort.

Exceptions

Exception | Condition
System..::.ArgumentNullException | source or keySelector is a null reference (Nothing in Visual Basic).

See Also

ParallelEnumerable Class
OrderByDescending Overload
System.Linq Namespace


OrderByDescending(TSource, TKey) Method (ParallelQuery(TSource), Func(TSource, TKey), IComparer(TKey))

[image]

.NET Framework Class Library
ParallelEnumerable..::.OrderByDescending<(Of <(TSource, TKey>)>) Method (ParallelQuery<(Of <(TSource>)>), Func<(Of <(TSource, TKey>)>), IComparer<(Of <(TKey>)>))
ParallelEnumerable Class See Also Send Feedback

Sorts the elements of a sequence in descending order by using a specified comparer.

Namespace: System.Linq
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function OrderByDescending(Of TSource, TKey) ( _
    source As ParallelQuery(Of TSource), _
    keySelector As Func(Of TSource, TKey), _
    comparer As IComparer(Of TKey) _
) As OrderedParallelQuery(Of TSource)
C#
public static OrderedParallelQuery<TSource> OrderByDescending<TSource, TKey>(
    ParallelQuery<TSource> source,
    Func<TSource, TKey> keySelector,
    IComparer<TKey> comparer
)

Parameters

source
Type: System.Linq..::.ParallelQuery <(Of <(TSource>)>)
A sequence of values to order.
keySelector
Type: System..::.Func<(Of <(TSource, TKey>)>)
A function to extract a key from an element.
comparer
Type: System.Collections.Generic..::.IComparer<(Of <(TKey>)>)
An IComparer{TKey} to compare keys.

Type Parameters

TSource
The type of elements of source.
TKey
The type of the key returned by keySelector.

Return Value

An OrderedParallelQuery{TSource} whose elements are sorted descending according to a key.

Remarks

In contrast to the sequential implementation, this is not a stable sort. See the remarks for OrderBy(ParallelQuery{TSource}, Func{TSource,TKey}) for an approach to implementing a stable sort.

Exceptions

Exception | Condition
System..::.ArgumentNullException | source or keySelector is a null reference (Nothing in Visual Basic).

See Also

ParallelEnumerable Class
OrderByDescending Overload
System.Linq Namespace


Range Method

[image]

.NET Framework Class Library
ParallelEnumerable..::.Range Method
ParallelEnumerable Class See Also Send Feedback

Generates a parallel sequence of integral numbers within a specified range.

Namespace: System.Linq
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function Range ( _
    start As Integer, _
    count As Integer _
) As ParallelQuery(Of Integer)
C#
public static ParallelQuery<int> Range(
    int start,
    int count
)

Parameters

start
Type: System..::.Int32
The value of the first integer in the sequence.
count
Type: System..::.Int32
The number of sequential integers to generate.

Return Value

An IEnumerable<Int32> in C# or IEnumerable(Of Int32) in Visual Basic that contains a range of sequential integral numbers.

Exceptions

Exception | Condition
System..::.ArgumentOutOfRangeException | count is less than 0 -or- start + count - 1 is larger than MaxValue()()().

See Also

ParallelEnumerable Class
System.Linq Namespace


Repeat(TResult) Method

[image]

.NET Framework Class Library
ParallelEnumerable..::.Repeat<(Of <(TResult>)>) Method
ParallelEnumerable Class See Also Send Feedback

Generates a parallel sequence that contains one repeated value.

Namespace: System.Linq
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function Repeat(Of TResult) ( _
    element As TResult, _
    count As Integer _
) As ParallelQuery(Of TResult)
C#
public static ParallelQuery<TResult> Repeat<TResult>(
    TResult element,
    int count
)

Parameters

element
Type: TResult
The value to be repeated.
count
Type: System..::.Int32
The number of times to repeat the value in the generated sequence.

Type Parameters

TResult
The type of the value to be repeated in the result sequence.

Return Value

A sequence that contains a repeated value.

Exceptions

Exception | Condition
System..::.ArgumentOutOfRangeException | count is less than 0.

See Also

ParallelEnumerable Class
System.Linq Namespace


Reverse(TSource) Method

[image]

.NET Framework Class Library
ParallelEnumerable..::.Reverse<(Of <(TSource>)>) Method
ParallelEnumerable Class See Also Send Feedback

Inverts the order of the elements in a parallel sequence.

Namespace: System.Linq
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function Reverse(Of TSource) ( _
    source As ParallelQuery(Of TSource) _
) As ParallelQuery(Of TSource)
C#
public static ParallelQuery<TSource> Reverse<TSource>(
    ParallelQuery<TSource> source
)

Parameters

source
Type: System.Linq..::.ParallelQuery <(Of <(TSource>)>)
A sequence of values to reverse.

Type Parameters

TSource
The type of the elements of source.

Return Value

A sequence whose elements correspond to those of the input sequence in reverse order.

Exceptions

Exception | Condition
System..::.ArgumentNullException | source is a null reference (Nothing in Visual Basic).

See Also

ParallelEnumerable Class
System.Linq Namespace


Select Method

[image] [image]

.NET Framework Class Library
ParallelEnumerable..::.Select Method
ParallelEnumerable Class See Also Send Feedback

Overload List

Name | Description
Select<(Of <(TSource, TResult>)>)(ParallelQuery<(Of <(TSource>)>), Func<(Of <(TSource, TResult>)>)) | Projects in parallel each element of a sequence into a new form.
Select<(Of <(TSource, TResult>)>)(ParallelQuery<(Of <(TSource>)>), Func<(Of <(TSource, Int32, TResult>)>)) | Projects in parallel each element of a sequence into a new form by incorporating the element's index.

See Also

ParallelEnumerable Class
System.Linq Namespace


Select(TSource, TResult) Method (ParallelQuery(TSource), Func(TSource, TResult))

[image]

.NET Framework Class Library
ParallelEnumerable..::.Select<(Of <(TSource, TResult>)>) Method (ParallelQuery<(Of <(TSource>)>), Func<(Of <(TSource, TResult>)>))
ParallelEnumerable Class See Also Send Feedback

Projects in parallel each element of a sequence into a new form.

Namespace: System.Linq
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function Select(Of TSource, TResult) ( _
    source As ParallelQuery(Of TSource), _
    selector As Func(Of TSource, TResult) _
) As ParallelQuery(Of TResult)
C#
public static ParallelQuery<TResult> Select<TSource, TResult>(
    ParallelQuery<TSource> source,
    Func<TSource, TResult> selector
)

Parameters

source
Type: System.Linq..::.ParallelQuery <(Of <(TSource>)>)
A sequence of values to invoke a transform function on.
selector
Type: System..::.Func<(Of <(TSource, TResult>)>)
A transform function to apply to each element.

Type Parameters

TSource
The type of the elements of source.
TResult
The type of elements resturned by selector.

Return Value

A sequence whose elements are the result of invoking the transform function on each element of source.

Exceptions

Exception | Condition
System..::.ArgumentNullException | source or selector is a null reference (Nothing in Visual Basic).

See Also

ParallelEnumerable Class
Select Overload
System.Linq Namespace


Select(TSource, TResult) Method (ParallelQuery(TSource), Func(TSource, Int32, TResult))

[image]

.NET Framework Class Library
ParallelEnumerable..::.Select<(Of <(TSource, TResult>)>) Method (ParallelQuery<(Of <(TSource>)>), Func<(Of <(TSource, Int32, TResult>)>))
ParallelEnumerable Class See Also Send Feedback

Projects in parallel each element of a sequence into a new form by incorporating the element's index.

Namespace: System.Linq
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function Select(Of TSource, TResult) ( _
    source As ParallelQuery(Of TSource), _
    selector As Func(Of TSource, Integer, TResult) _
) As ParallelQuery(Of TResult)
C#
public static ParallelQuery<TResult> Select<TSource, TResult>(
    ParallelQuery<TSource> source,
    Func<TSource, int, TResult> selector
)

Parameters

source
Type: System.Linq..::.ParallelQuery <(Of <(TSource>)>)
A sequence of values to invoke a transform function on.
selector
Type: System..::.Func<(Of <(TSource, Int32, TResult>)>)
A transform function to apply to each element.

Type Parameters

TSource
The type of the elements of source.
TResult
The type of elements resturned by selector.

Return Value

A sequence whose elements are the result of invoking the transform function on each element of source.

Exceptions

Exception | Condition
System..::.ArgumentNullException | source or selector is a null reference (Nothing in Visual Basic).

See Also

ParallelEnumerable Class
Select Overload
System.Linq Namespace


SelectMany Method

[image] [image]

.NET Framework Class Library
ParallelEnumerable..::.SelectMany Method
ParallelEnumerable Class See Also Send Feedback

Overload List

Name | Description
SelectMany<(Of <(TSource, TResult>)>)(ParallelQuery<(Of <(TSource>)>), Func<(Of <(TSource, IEnumerable<(Of <(TResult>)>)>)>)) | Projects in parallel each element of a sequence to an IEnumerable{T} and flattens the resulting sequences into one sequence.
SelectMany<(Of <(TSource, TResult>)>)(ParallelQuery<(Of <(TSource>)>), Func<(Of <(TSource, Int32, IEnumerable<(Of <(TResult>)>)>)>)) | Projects in parallel each element of a sequence to an IEnumerable{T}, and flattens the resulting sequences into one sequence. The index of each source element is used in the projected form of that element.
SelectMany<(Of <(TSource, TCollection, TResult>)>)(ParallelQuery<(Of <(TSource>)>), Func<(Of <(TSource, IEnumerable<(Of <(TCollection>)>)>)>), Func<(Of <(TSource, TCollection, TResult>)>)) | Projects each element of a sequence to an IEnumerable{T}, flattens the resulting sequences into one sequence, and invokes a result selector function on each element therein.
SelectMany<(Of <(TSource, TCollection, TResult>)>)(ParallelQuery<(Of <(TSource>)>), Func<(Of <(TSource, Int32, IEnumerable<(Of <(TCollection>)>)>)>), Func<(Of <(TSource, TCollection, TResult>)>)) | Projects each element of a sequence to an IEnumerable{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.

See Also

ParallelEnumerable Class
System.Linq Namespace


SelectMany(TSource, TResult) Method (ParallelQuery(TSource), Func(TSource, IEnumerable(TResult)))

[image]

.NET Framework Class Library
ParallelEnumerable..::.SelectMany<(Of <(TSource, TResult>)>) Method (ParallelQuery<(Of <(TSource>)>), Func<(Of <(TSource, IEnumerable<(Of <(TResult>)>)>)>))
ParallelEnumerable Class See Also Send Feedback

Projects in parallel each element of a sequence to an IEnumerable{T} and flattens the resulting sequences into one sequence.

Namespace: System.Linq
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function SelectMany(Of TSource, TResult) ( _
    source As ParallelQuery(Of TSource), _
    selector As Func(Of TSource, IEnumerable(Of TResult)) _
) As ParallelQuery(Of TResult)
C#
public static ParallelQuery<TResult> SelectMany<TSource, TResult>(
    ParallelQuery<TSource> source,
    Func<TSource, IEnumerable<TResult>> selector
)

Parameters

source
Type: System.Linq..::.ParallelQuery <(Of <(TSource>)>)
A sequence of values to project.
selector
Type: System..::.Func<(Of <(TSource, IEnumerable<(Of <(TResult>)>)>)>)
A transform function to apply to each element.

Type Parameters

TSource
The type of elements of source.
TResult
The type of the elements of the sequence returned by selector.

Return Value

A sequence whose elements are the result of invoking the one-to-many transform function on each element of the input sequence.

Exceptions

Exception | Condition
System..::.ArgumentNullException | source or selector is a null reference (Nothing in Visual Basic).

See Also

ParallelEnumerable Class
SelectMany Overload
System.Linq Namespace


SelectMany(TSource, TResult) Method (ParallelQuery(TSource), Func(TSource, Int32, IEnumerable(TResult)))

[image]

.NET Framework Class Library
ParallelEnumerable..::.SelectMany<(Of <(TSource, TResult>)>) Method (ParallelQuery<(Of <(TSource>)>), Func<(Of <(TSource, Int32, IEnumerable<(Of <(TResult>)>)>)>))
ParallelEnumerable Class See Also Send Feedback

Projects in parallel each element of a sequence to an IEnumerable{T}, and flattens the resulting sequences into one sequence. The index of each source element is used in the projected form of that element.

Namespace: System.Linq
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function SelectMany(Of TSource, TResult) ( _
    source As ParallelQuery(Of TSource), _
    selector As Func(Of TSource, Integer, IEnumerable(Of TResult)) _
) As ParallelQuery(Of TResult)
C#
public static ParallelQuery<TResult> SelectMany<TSource, TResult>(
    ParallelQuery<TSource> source,
    Func<TSource, int, IEnumerable<TResult>> selector
)

Parameters

source
Type: System.Linq..::.ParallelQuery <(Of <(TSource>)>)
A sequence of values to project.
selector
Type: System..::.Func<(Of <(TSource, Int32, IEnumerable<(Of <(TResult>)>)>)>)
A transform function to apply to each element.

Type Parameters

TSource
The type of elements of source.
TResult
The type of the elements of the sequence returned by selector.

Return Value

A sequence whose elements are the result of invoking the one-to-many transform function on each element of the input sequence.

Exceptions

Exception | Condition
System..::.ArgumentNullException | source or selector is a null reference (Nothing in Visual Basic).

See Also

ParallelEnumerable Class
SelectMany Overload
System.Linq Namespace


SelectMany(TSource, TCollection, TResult) Method (ParallelQuery(TSource), Func(TSource, IEnumerable(TCollection)), Func(TSource, TCollection, TResult))

[image]

.NET Framework Class Library
ParallelEnumerable..::.SelectMany<(Of <(TSource, TCollection, TResult>)>) Method (ParallelQuery<(Of <(TSource>)>), Func<(Of <(TSource, IEnumerable<(Of <(TCollection>)>)>)>), Func<(Of <(TSource, TCollection, TResult>)>))
ParallelEnumerable Class See Also Send Feedback

Projects each element of a sequence to an IEnumerable{T}, flattens the resulting sequences into one sequence, and invokes a result selector function on each element therein.

Namespace: System.Linq
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function SelectMany(Of TSource, TCollection, TResult) ( _
    source As ParallelQuery(Of TSource), _
    collectionSelector As Func(Of TSource, IEnumerable(Of TCollection)), _
    resultSelector As Func(Of TSource, TCollection, TResult) _
) As ParallelQuery(Of TResult)
C#
public static ParallelQuery<TResult> SelectMany<TSource, TCollection, TResult>(
    ParallelQuery<TSource> source,
    Func<TSource, IEnumerable<TCollection>> collectionSelector,
    Func<TSource, TCollection, TResult> resultSelector
)

Parameters

source
Type: System.Linq..::.ParallelQuery <(Of <(TSource>)>)
A sequence of values to project.
collectionSelector
Type: System..::.Func<(Of <(TSource, IEnumerable<(Of <(TCollection>)>)>)>)
A transform function to apply to each source element; the second parameter of the function represents the index of the source element.
resultSelector
Type: System..::.Func<(Of <(TSource, TCollection, TResult>)>)
A function to create a result element from an element from the first sequence and a collection of matching elements from the second sequence.

Type Parameters

TSource
The type of elements of source.
TCollection
The type of the intermediate elements collected by collectionSelector.
TResult

Return Value

A sequence whose elements are the result of invoking the one-to-many transform function collectionSelector on each element of source and then mapping each of those sequence elements and their corresponding source element to a result element.

Exceptions

Exception | Condition
System..::.ArgumentNullException | source or collectionSelector or resultSelector is a null reference (Nothing in Visual Basic).

See Also

ParallelEnumerable Class
SelectMany Overload
System.Linq Namespace


SelectMany(TSource, TCollection, TResult) Method (ParallelQuery(TSource), Func(TSource, Int32, IEnumerable(TCollection)), Func(TSource, TCollection, TResult))

[image]

.NET Framework Class Library
ParallelEnumerable..::.SelectMany<(Of <(TSource, TCollection, TResult>)>) Method (ParallelQuery<(Of <(TSource>)>), Func<(Of <(TSource, Int32, IEnumerable<(Of <(TCollection>)>)>)>), Func<(Of <(TSource, TCollection, TResult>)>))
ParallelEnumerable Class See Also Send Feedback

Projects each element of a sequence to an IEnumerable{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.

Namespace: System.Linq
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function SelectMany(Of TSource, TCollection, TResult) ( _
    source As ParallelQuery(Of TSource), _
    collectionSelector As Func(Of TSource, Integer, IEnumerable(Of TCollection)), _
    resultSelector As Func(Of TSource, TCollection, TResult) _
) As ParallelQuery(Of TResult)
C#
public static ParallelQuery<TResult> SelectMany<TSource, TCollection, TResult>(
    ParallelQuery<TSource> source,
    Func<TSource, int, IEnumerable<TCollection>> collectionSelector,
    Func<TSource, TCollection, TResult> resultSelector
)

Parameters

source
Type: System.Linq..::.ParallelQuery <(Of <(TSource>)>)
A sequence of values to project.
collectionSelector
Type: System..::.Func<(Of <(TSource, Int32, IEnumerable<(Of <(TCollection>)>)>)>)
A transform function to apply to each source element; the second parameter of the function represents the index of the source element.
resultSelector
Type: System..::.Func<(Of <(TSource, TCollection, TResult>)>)
A function to create a result element from an element from the first sequence and a collection of matching elements from the second sequence.

Type Parameters

TSource
The type of elements of source.
TCollection
The type of the intermediate elements collected by collectionSelector.
TResult
The type of elements to return.

Return Value

A sequence whose elements are the result of invoking the one-to-many transform function collectionSelector on each element of source and then mapping each of those sequence elements and their corresponding source element to a result element.

Exceptions

Exception | Condition
System..::.ArgumentNullException | source or collectionSelector or resultSelector is a null reference (Nothing in Visual Basic).

See Also

ParallelEnumerable Class
SelectMany Overload
System.Linq Namespace


SequenceEqual Method

[image] [image]

.NET Framework Class Library
ParallelEnumerable..::.SequenceEqual Method
ParallelEnumerable Class See Also Send Feedback

Overload List

Name | Description
SequenceEqual<(Of <(TSource>)>)(ParallelQuery<(Of <(TSource>)>), IEnumerable<(Of <(TSource>)>)) | Obsolete. This SequenceEqual overload should never be called. This method is marked as obsolete and always throws NotSupportedException when called.
SequenceEqual<(Of <(TSource>)>)(ParallelQuery<(Of <(TSource>)>), ParallelQuery<(Of <(TSource>)>)) | Determines whether two parallel sequences are equal by comparing the elements by using the default equality comparer for their type.
SequenceEqual<(Of <(TSource>)>)(ParallelQuery<(Of <(TSource>)>), IEnumerable<(Of <(TSource>)>), IEqualityComparer<(Of <(TSource>)>)) | Obsolete. This SequenceEqual overload should never be called. This method is marked as obsolete and always throws NotSupportedException when called.
SequenceEqual<(Of <(TSource>)>)(ParallelQuery<(Of <(TSource>)>), ParallelQuery<(Of <(TSource>)>), IEqualityComparer<(Of <(TSource>)>)) | Determines whether two parallel sequences are equal by comparing their elements by using a specified IEqualityComparer{T}.

See Also

ParallelEnumerable Class
System.Linq Namespace


SequenceEqual(TSource) Method (ParallelQuery(TSource), IEnumerable(TSource))

[image]

.NET Framework Class Library
ParallelEnumerable..::.SequenceEqual<(Of <(TSource>)>) Method (ParallelQuery<(Of <(TSource>)>), IEnumerable<(Of <(TSource>)>))
ParallelEnumerable Class See Also Send Feedback

This SequenceEqual overload should never be called. This method is marked as obsolete and always throws NotSupportedException when called.

Namespace: System.Linq
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
<ObsoleteAttribute("The second data source of a binary operator must be of type System.Linq.ParallelQuery<T> rather than System.Collections.Generic.IEnumerable<T>. To fix this problem, use the AsParallel() extension method to convert the right data source to System.Linq.ParallelQuery<T>.")> _
Public Shared Function SequenceEqual(Of TSource) ( _
    first As ParallelQuery(Of TSource), _
    second As IEnumerable(Of TSource) _
) As Boolean
C#
[ObsoleteAttribute("The second data source of a binary operator must be of type System.Linq.ParallelQuery<T> rather than System.Collections.Generic.IEnumerable<T>. To fix this problem, use the AsParallel() extension method to convert the right data source to System.Linq.ParallelQuery<T>.")]
public static bool SequenceEqual<TSource>(
    ParallelQuery<TSource> first,
    IEnumerable<TSource> second
)

Parameters

first
Type: System.Linq..::.ParallelQuery <(Of <(TSource>)>)
This parameter is not used.
second
Type: System.Collections.Generic..::.IEnumerable<(Of <(TSource>)>)
This parameter is not used.

Type Parameters

TSource
This type parameter is not used.

Return Value

This overload always throws a NotSupportedException.

Remarks

This overload exists to disallow usage of SequenceEqual with a left data source of type ParallelQuery<(Of <(TSource>)>) and a right data source of type IEnumerable<(Of <(T>)>). Otherwise, the SequenceEqual operator would appear to be binding to the parallel implementation, but would in reality bind to the sequential implementation.

Exceptions

Exception | Condition
System..::.NotSupportedException | Thrown every time this method is called.

See Also

ParallelEnumerable Class
SequenceEqual Overload
System.Linq Namespace


SequenceEqual(TSource) Method (ParallelQuery(TSource), ParallelQuery(TSource))

[image]

.NET Framework Class Library
ParallelEnumerable..::.SequenceEqual<(Of <(TSource>)>) Method (ParallelQuery<(Of <(TSource>)>), ParallelQuery<(Of <(TSource>)>))
ParallelEnumerable Class See Also Send Feedback

Determines whether two parallel sequences are equal by comparing the elements by using the default equality comparer for their type.

Namespace: System.Linq
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function SequenceEqual(Of TSource) ( _
    first As ParallelQuery(Of TSource), _
    second As ParallelQuery(Of TSource) _
) As Boolean
C#
public static bool SequenceEqual<TSource>(
    ParallelQuery<TSource> first,
    ParallelQuery<TSource> second
)

Parameters

first
Type: System.Linq..::.ParallelQuery <(Of <(TSource>)>)
A sequence to compare to second.
second
Type: System.Linq..::.ParallelQuery <(Of <(TSource>)>)
A sequence to compare to the first input sequence.

Type Parameters

TSource
The type of the elements of the input sequences.

Return Value

true if the two source sequences are of equal length and their corresponding elements are equal according to the default equality comparer for their type; otherwise, false.

Exceptions

Exception | Condition
System..::.ArgumentNullException | first or second is a null reference (Nothing in Visual Basic).
System..::.AggregateException | One or more exceptions occurred during the evaluation of the query.
System..::.OperationCanceledException | The query was canceled.

See Also

ParallelEnumerable Class
SequenceEqual Overload
System.Linq Namespace


SequenceEqual(TSource) Method (ParallelQuery(TSource), IEnumerable(TSource), IEqualityComparer(TSource))

[image]

.NET Framework Class Library
ParallelEnumerable..::.SequenceEqual<(Of <(TSource>)>) Method (ParallelQuery<(Of <(TSource>)>), IEnumerable<(Of <(TSource>)>), IEqualityComparer<(Of <(TSource>)>))
ParallelEnumerable Class See Also Send Feedback

This SequenceEqual overload should never be called. This method is marked as obsolete and always throws NotSupportedException when called.

Namespace: System.Linq
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
<ObsoleteAttribute("The second data source of a binary operator must be of type System.Linq.ParallelQuery<T> rather than System.Collections.Generic.IEnumerable<T>. To fix this problem, use the AsParallel() extension method to convert the right data source to System.Linq.ParallelQuery<T>.")> _
Public Shared Function SequenceEqual(Of TSource) ( _
    first As ParallelQuery(Of TSource), _
    second As IEnumerable(Of TSource), _
    comparer As IEqualityComparer(Of TSource) _
) As Boolean
C#
[ObsoleteAttribute("The second data source of a binary operator must be of type System.Linq.ParallelQuery<T> rather than System.Collections.Generic.IEnumerable<T>. To fix this problem, use the AsParallel() extension method to convert the right data source to System.Linq.ParallelQuery<T>.")]
public static bool SequenceEqual<TSource>(
    ParallelQuery<TSource> first,
    IEnumerable<TSource> second,
    IEqualityComparer<TSource> comparer
)

Parameters

first
Type: System.Linq..::.ParallelQuery <(Of <(TSource>)>)
This parameter is not used.
second
Type: System.Collections.Generic..::.IEnumerable<(Of <(TSource>)>)
This parameter is not used.
comparer
Type: System.Collections.Generic..::.IEqualityComparer<(Of <(TSource>)>)
This parameter is not used.

Type Parameters

TSource
This type parameter is not used.

Return Value

This overload always throws a NotSupportedException.

Remarks

This overload exists to disallow usage of SequenceEqual with a left data source of type ParallelQuery<(Of <(TSource>)>) and a right data source of type IEnumerable<(Of <(T>)>). Otherwise, the SequenceEqual operator would appear to be binding to the parallel implementation, but would in reality bind to sequential implementation.

Exceptions

Exception | Condition
System..::.NotSupportedException | Thrown every time this method is called.

See Also

ParallelEnumerable Class
SequenceEqual Overload
System.Linq Namespace


SequenceEqual(TSource) Method (ParallelQuery(TSource), ParallelQuery(TSource), IEqualityComparer(TSource))

[image]

.NET Framework Class Library
ParallelEnumerable..::.SequenceEqual<(Of <(TSource>)>) Method (ParallelQuery<(Of <(TSource>)>), ParallelQuery<(Of <(TSource>)>), IEqualityComparer<(Of <(TSource>)>))
ParallelEnumerable Class See Also Send Feedback

Determines whether two parallel sequences are equal by comparing their elements by using a specified IEqualityComparer{T}.

Namespace: System.Linq
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function SequenceEqual(Of TSource) ( _
    first As ParallelQuery(Of TSource), _
    second As ParallelQuery(Of TSource), _
    comparer As IEqualityComparer(Of TSource) _
) As Boolean
C#
public static bool SequenceEqual<TSource>(
    ParallelQuery<TSource> first,
    ParallelQuery<TSource> second,
    IEqualityComparer<TSource> comparer
)

Parameters

first
Type: System.Linq..::.ParallelQuery <(Of <(TSource>)>)
A sequence to compare to second.
second
Type: System.Linq..::.ParallelQuery <(Of <(TSource>)>)
A sequence to compare to the first input sequence.
comparer
Type: System.Collections.Generic..::.IEqualityComparer<(Of <(TSource>)>)
An IEqualityComparer<(Of <(T>)>) to use to compare elements.

Type Parameters

TSource
The type of the elements of the input sequences.

Return Value

true if the two source sequences are of equal length and their corresponding elements are equal according to the default equality comparer for their type; otherwise, false.

Exceptions

Exception | Condition
System..::.ArgumentNullException | first or second is a null reference (Nothing in Visual Basic).
System..::.AggregateException | One or more exceptions occurred during the evaluation of the query.
System..::.OperationCanceledException | The query was canceled.

See Also

ParallelEnumerable Class
SequenceEqual Overload
System.Linq Namespace


Single Method

[image] [image]

.NET Framework Class Library
ParallelEnumerable..::.Single Method
ParallelEnumerable Class See Also Send Feedback

Overload List

Name | Description
Single<(Of <(TSource>)>)(ParallelQuery<(Of <(TSource>)>)) | Returns the only element of a parallel sequence, and throws an exception if there is not exactly one element in the sequence.
Single<(Of <(TSource>)>)(ParallelQuery<(Of <(TSource>)>), Func<(Of <(TSource, Boolean>)>)) | Returns the only element of a parallel sequence that satisfies a specified condition, and throws an exception if more than one such element exists.

See Also

ParallelEnumerable Class
System.Linq Namespace


Single(TSource) Method (ParallelQuery(TSource))

[image]

.NET Framework Class Library
ParallelEnumerable..::.Single<(Of <(TSource>)>) Method (ParallelQuery<(Of <(TSource>)>))
ParallelEnumerable Class See Also Send Feedback

Returns the only element of a parallel sequence, and throws an exception if there is not exactly one element in the sequence.

Namespace: System.Linq
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function Single(Of TSource) ( _
    source As ParallelQuery(Of TSource) _
) As TSource
C#
public static TSource Single<TSource>(
    ParallelQuery<TSource> source
)

Parameters

source
Type: System.Linq..::.ParallelQuery <(Of <(TSource>)>)
The sequence to return the single element of.

Type Parameters

TSource
The type of the elements of source.

Return Value

The single element of the input sequence.

Exceptions

Exception | Condition
System..::.ArgumentNullException | source is a null reference (Nothing in Visual Basic).
System..::.InvalidOperationException | The input sequence contains more than one element. -or- The input sequence is empty.
System..::.AggregateException | One or more exceptions occurred during the evaluation of the query.
System..::.OperationCanceledException | The query was canceled.

See Also

ParallelEnumerable Class
Single Overload
System.Linq Namespace


Single(TSource) Method (ParallelQuery(TSource), Func(TSource, Boolean))

[image]

.NET Framework Class Library
ParallelEnumerable..::.Single<(Of <(TSource>)>) Method (ParallelQuery<(Of <(TSource>)>), Func<(Of <(TSource, Boolean>)>))
ParallelEnumerable Class See Also Send Feedback

Returns the only element of a parallel sequence that satisfies a specified condition, and throws an exception if more than one such element exists.

Namespace: System.Linq
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function Single(Of TSource) ( _
    source As ParallelQuery(Of TSource), _
    predicate As Func(Of TSource, Boolean) _
) As TSource
C#
public static TSource Single<TSource>(
    ParallelQuery<TSource> source,
    Func<TSource, bool> predicate
)

Parameters

source
Type: System.Linq..::.ParallelQuery <(Of <(TSource>)>)
The sequence to return the single element of.
predicate
Type: System..::.Func<(Of <(TSource, Boolean>)>)
A function to test an element for a condition.

Type Parameters

TSource
The type of the elements of source.

Return Value

The single element of the input sequence that satisfies a condition.

Exceptions

Exception | Condition
System..::.ArgumentNullException | source or predicate is a null reference (Nothing in Visual Basic).
System..::.InvalidOperationException | No element satisfies the condition in predicate. -or- More than one element satisfies the condition in predicate.
System..::.AggregateException | One or more exceptions occurred during the evaluation of the query.
System..::.OperationCanceledException | The query was canceled.

See Also

ParallelEnumerable Class
Single Overload
System.Linq Namespace


SingleOrDefault Method

[image] [image]

.NET Framework Class Library
ParallelEnumerable..::.SingleOrDefault Method
ParallelEnumerable Class See Also Send Feedback

Overload List

Name | Description
SingleOrDefault<(Of <(TSource>)>)(ParallelQuery<(Of <(TSource>)>)) | Returns the only element of a parallel 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.
SingleOrDefault<(Of <(TSource>)>)(ParallelQuery<(Of <(TSource>)>), Func<(Of <(TSource, Boolean>)>)) | Returns the only element of a parallel 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.

See Also

ParallelEnumerable Class
System.Linq Namespace


SingleOrDefault(TSource) Method (ParallelQuery(TSource))

[image]

.NET Framework Class Library
ParallelEnumerable..::.SingleOrDefault<(Of <(TSource>)>) Method (ParallelQuery<(Of <(TSource>)>))
ParallelEnumerable Class See Also Send Feedback

Returns the only element of a parallel 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.

Namespace: System.Linq
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function SingleOrDefault(Of TSource) ( _
    source As ParallelQuery(Of TSource) _
) As TSource
C#
public static TSource SingleOrDefault<TSource>(
    ParallelQuery<TSource> source
)

Parameters

source
Type: System.Linq..::.ParallelQuery <(Of <(TSource>)>)
The sequence to return the single element of.

Type Parameters

TSource
The type of the elements of source.

Return Value

The single element of the input sequence, or default(TSource) if the sequence contains no elements.

Exceptions

Exception | Condition
System..::.ArgumentNullException | source is a null reference (Nothing in Visual Basic).
System..::.AggregateException | One or more exceptions occurred during the evaluation of the query.
System..::.OperationCanceledException | The query was canceled.

See Also

ParallelEnumerable Class
SingleOrDefault Overload
System.Linq Namespace


SingleOrDefault(TSource) Method (ParallelQuery(TSource), Func(TSource, Boolean))

[image]

.NET Framework Class Library
ParallelEnumerable..::.SingleOrDefault<(Of <(TSource>)>) Method (ParallelQuery<(Of <(TSource>)>), Func<(Of <(TSource, Boolean>)>))
ParallelEnumerable Class See Also Send Feedback

Returns the only element of a parallel 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.

Namespace: System.Linq
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function SingleOrDefault(Of TSource) ( _
    source As ParallelQuery(Of TSource), _
    predicate As Func(Of TSource, Boolean) _
) As TSource
C#
public static TSource SingleOrDefault<TSource>(
    ParallelQuery<TSource> source,
    Func<TSource, bool> predicate
)

Parameters

source
Type: System.Linq..::.ParallelQuery <(Of <(TSource>)>)
The sequence to return the single element of.
predicate
Type: System..::.Func<(Of <(TSource, Boolean>)>)
A function to test an element for a condition.

Type Parameters

TSource
The type of the elements of source.

Return Value

The single element of the input sequence that satisfies the condition, or default(TSource) if no such element is found.

Exceptions

Exception | Condition
System..::.ArgumentNullException | source or predicate is a null reference (Nothing in Visual Basic).
System..::.AggregateException | One or more exceptions occurred during the evaluation of the query.
System..::.OperationCanceledException | The query was canceled.

See Also

ParallelEnumerable Class
SingleOrDefault Overload
System.Linq Namespace


Skip(TSource) Method

[image]

.NET Framework Class Library
ParallelEnumerable..::.Skip<(Of <(TSource>)>) Method
ParallelEnumerable Class See Also Send Feedback

Bypasses a specified number of elements in a parallel sequence and then returns the remaining elements.

Namespace: System.Linq
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function Skip(Of TSource) ( _
    source As ParallelQuery(Of TSource), _
    count As Integer _
) As ParallelQuery(Of TSource)
C#
public static ParallelQuery<TSource> Skip<TSource>(
    ParallelQuery<TSource> source,
    int count
)

Parameters

source
Type: System.Linq..::.ParallelQuery <(Of <(TSource>)>)
The sequence to return elements from.
count
Type: System..::.Int32
The number of elements to skip before returning the remaining elements.

Type Parameters

TSource
The type of elements of source.

Return Value

A sequence that contains the elements that occur after the specified index in the input sequence.

Exceptions

Exception | Condition
System..::.ArgumentNullException | source is a null reference (Nothing in Visual Basic).

See Also

ParallelEnumerable Class
System.Linq Namespace


SkipWhile Method

[image] [image]

.NET Framework Class Library
ParallelEnumerable..::.SkipWhile Method
ParallelEnumerable Class See Also Send Feedback

Overload List

Name | Description
SkipWhile<(Of <(TSource>)>)(ParallelQuery<(Of <(TSource>)>), Func<(Of <(TSource, Boolean>)>)) | Bypasses elements in a parallel sequence as long as a specified condition is true and then returns the remaining elements.
SkipWhile<(Of <(TSource>)>)(ParallelQuery<(Of <(TSource>)>), Func<(Of <(TSource, Int32, Boolean>)>)) | Bypasses elements in a parallel 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.

See Also

ParallelEnumerable Class
System.Linq Namespace


SkipWhile(TSource) Method (ParallelQuery(TSource), Func(TSource, Boolean))

[image]

.NET Framework Class Library
ParallelEnumerable..::.SkipWhile<(Of <(TSource>)>) Method (ParallelQuery<(Of <(TSource>)>), Func<(Of <(TSource, Boolean>)>))
ParallelEnumerable Class See Also Send Feedback

Bypasses elements in a parallel sequence as long as a specified condition is true and then returns the remaining elements.

Namespace: System.Linq
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function SkipWhile(Of TSource) ( _
    source As ParallelQuery(Of TSource), _
    predicate As Func(Of TSource, Boolean) _
) As ParallelQuery(Of TSource)
C#
public static ParallelQuery<TSource> SkipWhile<TSource>(
    ParallelQuery<TSource> source,
    Func<TSource, bool> predicate
)

Parameters

source
Type: System.Linq..::.ParallelQuery <(Of <(TSource>)>)
The sequence to return elements from.
predicate
Type: System..::.Func<(Of <(TSource, Boolean>)>)
A function to test each element for a condition.

Type Parameters

TSource
The type of elements of source.

Return Value

A sequence that contains the elements from the input sequence starting at the first element in the linear series that does not pass the test specified by predicate.

Exceptions

Exception | Condition
System..::.ArgumentNullException | source or predicate is a null reference (Nothing in Visual Basic).

See Also

ParallelEnumerable Class
SkipWhile Overload
System.Linq Namespace


SkipWhile(TSource) Method (ParallelQuery(TSource), Func(TSource, Int32, Boolean))

[image]

.NET Framework Class Library
ParallelEnumerable..::.SkipWhile<(Of <(TSource>)>) Method (ParallelQuery<(Of <(TSource>)>), Func<(Of <(TSource, Int32, Boolean>)>))
ParallelEnumerable Class See Also Send Feedback

Bypasses elements in a parallel 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.

Namespace: System.Linq
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function SkipWhile(Of TSource) ( _
    source As ParallelQuery(Of TSource), _
    predicate As Func(Of TSource, Integer, Boolean) _
) As ParallelQuery(Of TSource)
C#
public static ParallelQuery<TSource> SkipWhile<TSource>(
    ParallelQuery<TSource> source,
    Func<TSource, int, bool> predicate
)

Parameters

source
Type: System.Linq..::.ParallelQuery <(Of <(TSource>)>)
The sequence to return elements from.
predicate
Type: System..::.Func<(Of <(TSource, Int32, Boolean>)>)
A function to test each source element for a condition; the second parameter of the function represents the index of the source element.

Type Parameters

TSource
The type of elements of source.

Return Value

A sequence that contains the elements from the input sequence starting at the first element in the linear series that does not pass the test specified by predicate.

Exceptions

Exception | Condition
System..::.ArgumentNullException | source or predicate is a null reference (Nothing in Visual Basic).

See Also

ParallelEnumerable Class
SkipWhile Overload
System.Linq Namespace


Sum Method

[image] [image]

.NET Framework Class Library
ParallelEnumerable..::.Sum Method
ParallelEnumerable Class See Also Send Feedback

Overload List

Name | Description
Sum(ParallelQuery<(Of <(Decimal>)>)) | Computes in parallel the sum of a sequence of values.
Sum(ParallelQuery<(Of <(Double>)>)) | Computes in parallel the sum of a sequence of values.
Sum(ParallelQuery<(Of <(Int32>)>)) | Computes in parallel the sum of a sequence of values.
Sum(ParallelQuery<(Of <(Int64>)>)) | Computes in parallel the sum of a sequence of values.
Sum(ParallelQuery<(Of <(Nullable<(Of <(Decimal>)>)>)>)) | Computes in parallel the sum of a sequence of values.
Sum(ParallelQuery<(Of <(Nullable<(Of <(Double>)>)>)>)) | Computes in parallel the sum of a sequence of values.
Sum(ParallelQuery<(Of <(Nullable<(Of <(Int32>)>)>)>)) | Computes in parallel the sum of a sequence of values.
Sum(ParallelQuery<(Of <(Nullable<(Of <(Int64>)>)>)>)) | Computes in parallel the sum of a sequence of values.
Sum(ParallelQuery<(Of <(Nullable<(Of <(Single>)>)>)>)) | Computes in parallel the sum of a sequence of values.
Sum(ParallelQuery<(Of <(Single>)>)) | Computes in parallel the sum of a sequence of values.
Sum<(Of <(TSource>)>)(ParallelQuery<(Of <(TSource>)>), Func<(Of <(TSource, Decimal>)>)) | Computes in parallel the sum of the sequence of values that are obtained by invoking a transform function on each element of the input sequence.
Sum<(Of <(TSource>)>)(ParallelQuery<(Of <(TSource>)>), Func<(Of <(TSource, Double>)>)) | Computes in parallel the sum of the sequence of values that are obtained by invoking a transform function on each element of the input sequence.
Sum<(Of <(TSource>)>)(ParallelQuery<(Of <(TSource>)>), Func<(Of <(TSource, Int32>)>)) | Computes in parallel the sum of the sequence of values that are obtained by invoking a transform function on each element of the input sequence.
Sum<(Of <(TSource>)>)(ParallelQuery<(Of <(TSource>)>), Func<(Of <(TSource, Int64>)>)) | Computes in parallel the sum of the sequence of values that are obtained by invoking a transform function on each element of the input sequence.
Sum<(Of <(TSource>)>)(ParallelQuery<(Of <(TSource>)>), Func<(Of <(TSource, Nullable<(Of <(Decimal>)>)>)>)) | Computes in parallel the sum of the sequence of values that are obtained by invoking a transform function on each element of the input sequence.
Sum<(Of <(TSource>)>)(ParallelQuery<(Of <(TSource>)>), Func<(Of <(TSource, Nullable<(Of <(Double>)>)>)>)) | Computes in parallel the sum of the sequence of values that are obtained by invoking a transform function on each element of the input sequence.
Sum<(Of <(TSource>)>)(ParallelQuery<(Of <(TSource>)>), Func<(Of <(TSource, Nullable<(Of <(Int32>)>)>)>)) | Computes in parallel the sum of the sequence of values that are obtained by invoking a transform function on each element of the input sequence.
Sum<(Of <(TSource>)>)(ParallelQuery<(Of <(TSource>)>), Func<(Of <(TSource, Nullable<(Of <(Int64>)>)>)>)) | Computes in parallel the sum of the sequence of values that are obtained by invoking a transform function on each element of the input sequence.
Sum<(Of <(TSource>)>)(ParallelQuery<(Of <(TSource>)>), Func<(Of <(TSource, Nullable<(Of <(Single>)>)>)>)) | Computes in parallel the sum of the sequence of values that are obtained by invoking a transform function on each element of the input sequence.
Sum<(Of <(TSource>)>)(ParallelQuery<(Of <(TSource>)>), Func<(Of <(TSource, Single>)>)) | Computes in parallel the sum of the sequence of values that are obtained by invoking a transform function on each element of the input sequence.

See Also

ParallelEnumerable Class
System.Linq Namespace


Sum Method (ParallelQuery(Decimal))

[image]

.NET Framework Class Library
ParallelEnumerable..::.Sum Method (ParallelQuery<(Of <(Decimal>)>))
ParallelEnumerable Class See Also Send Feedback

Computes in parallel the sum of a sequence of values.

Namespace: System.Linq
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function Sum ( _
    source As ParallelQuery(Of Decimal) _
) As Decimal
C#
public static decimal Sum(
    ParallelQuery<decimal> source
)

Parameters

source
Type: System.Linq..::.ParallelQuery <(Of <(Decimal>)>)
A sequence of values to calculate the sum of.

Return Value

The sum of the values in the sequence.

Exceptions

Exception | Condition
System..::.ArgumentNullException | source is a null reference (Nothing in Visual Basic).
System..::.AggregateException | The sum is larger than MaxValue()()(). -or- One or more exceptions occurred during the evaluation of the query.
System..::.OperationCanceledException | The query was canceled.

See Also

ParallelEnumerable Class
Sum Overload
System.Linq Namespace


Sum Method (ParallelQuery(Double))

[image]

.NET Framework Class Library
ParallelEnumerable..::.Sum Method (ParallelQuery<(Of <(Double>)>))
ParallelEnumerable Class See Also Send Feedback

Computes in parallel the sum of a sequence of values.

Namespace: System.Linq
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function Sum ( _
    source As ParallelQuery(Of Double) _
) As Double
C#
public static double Sum(
    ParallelQuery<double> source
)

Parameters

source
Type: System.Linq..::.ParallelQuery <(Of <(Double>)>)
A sequence of values to calculate the sum of.

Return Value

The sum of the values in the sequence.

Exceptions

Exception | Condition
System..::.ArgumentNullException | source is a null reference (Nothing in Visual Basic).
System..::.AggregateException | One or more exceptions occurred during the evaluation of the query.
System..::.OperationCanceledException | The query was canceled.

See Also

ParallelEnumerable Class
Sum Overload
System.Linq Namespace


Sum Method (ParallelQuery(Int32))

[image]

.NET Framework Class Library
ParallelEnumerable..::.Sum Method (ParallelQuery<(Of <(Int32>)>))
ParallelEnumerable Class See Also Send Feedback

Computes in parallel the sum of a sequence of values.

Namespace: System.Linq
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function Sum ( _
    source As ParallelQuery(Of Integer) _
) As Integer
C#
public static int Sum(
    ParallelQuery<int> source
)

Parameters

source
Type: System.Linq..::.ParallelQuery <(Of <(Int32>)>)
A sequence of values to calculate the sum of.

Return Value

The sum of the values in the sequence.

Exceptions

Exception | Condition
System..::.ArgumentNullException | source is a null reference (Nothing in Visual Basic).
System..::.AggregateException | The sum is larger than MaxValue()()(). -or- One or more exceptions occurred during the evaluation of the query.
System..::.OperationCanceledException | The query was canceled.

See Also

ParallelEnumerable Class
Sum Overload
System.Linq Namespace


Sum Method (ParallelQuery(Int64))

[image]

.NET Framework Class Library
ParallelEnumerable..::.Sum Method (ParallelQuery<(Of <(Int64>)>))
ParallelEnumerable Class See Also Send Feedback

Computes in parallel the sum of a sequence of values.

Namespace: System.Linq
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function Sum ( _
    source As ParallelQuery(Of Long) _
) As Long
C#
public static long Sum(
    ParallelQuery<long> source
)

Parameters

source
Type: System.Linq..::.ParallelQuery <(Of <(Int64>)>)
A sequence of values to calculate the sum of.

Return Value

The sum of the values in the sequence.

Exceptions

Exception | Condition
System..::.ArgumentNullException | source is a null reference (Nothing in Visual Basic).
System..::.AggregateException | The sum is larger than MaxValue()()(). -or- One or more exceptions occurred during the evaluation of the query.
System..::.OperationCanceledException | The query was canceled.

See Also

ParallelEnumerable Class
Sum Overload
System.Linq Namespace


Sum Method (ParallelQuery(Nullable(Decimal)))

[image]

.NET Framework Class Library
ParallelEnumerable..::.Sum Method (ParallelQuery<(Of <(Nullable<(Of <(Decimal>)>)>)>))
ParallelEnumerable Class See Also Send Feedback

Computes in parallel the sum of a sequence of values.

Namespace: System.Linq
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function Sum ( _
    source As ParallelQuery(Of Nullable(Of Decimal)) _
) As Nullable(Of Decimal)
C#
public static Nullable<decimal> Sum(
    ParallelQuery<Nullable<decimal>> source
)

Parameters

source
Type: System.Linq..::.ParallelQuery <(Of <(Nullable<(Of <(Decimal>)>)>)>)
A sequence of values to calculate the sum of.

Return Value

The sum of the values in the sequence.

Exceptions

Exception | Condition
System..::.ArgumentNullException | source is a null reference (Nothing in Visual Basic).
System..::.AggregateException | The sum is larger than MaxValue()()(). -or- One or more exceptions occurred during the evaluation of the query.
System..::.OperationCanceledException | The query was canceled.

See Also

ParallelEnumerable Class
Sum Overload
System.Linq Namespace


Sum Method (ParallelQuery(Nullable(Double)))

[image]

.NET Framework Class Library
ParallelEnumerable..::.Sum Method (ParallelQuery<(Of <(Nullable<(Of <(Double>)>)>)>))
ParallelEnumerable Class See Also Send Feedback

Computes in parallel the sum of a sequence of values.

Namespace: System.Linq
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function Sum ( _
    source As ParallelQuery(Of Nullable(Of Double)) _
) As Nullable(Of Double)
C#
public static Nullable<double> Sum(
    ParallelQuery<Nullable<double>> source
)

Parameters

source
Type: System.Linq..::.ParallelQuery <(Of <(Nullable<(Of <(Double>)>)>)>)
A sequence of values to calculate the sum of.

Return Value

The sum of the values in the sequence.

Exceptions

Exception | Condition
System..::.ArgumentNullException | source is a null reference (Nothing in Visual Basic).
System..::.AggregateException | One or more exceptions occurred during the evaluation of the query.
System..::.OperationCanceledException | The query was canceled.

See Also

ParallelEnumerable Class
Sum Overload
System.Linq Namespace


Sum Method (ParallelQuery(Nullable(Int32)))

[image]

.NET Framework Class Library
ParallelEnumerable..::.Sum Method (ParallelQuery<(Of <(Nullable<(Of <(Int32>)>)>)>))
ParallelEnumerable Class See Also Send Feedback

Computes in parallel the sum of a sequence of values.

Namespace: System.Linq
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function Sum ( _
    source As ParallelQuery(Of Nullable(Of Integer)) _
) As Nullable(Of Integer)
C#
public static Nullable<int> Sum(
    ParallelQuery<Nullable<int>> source
)

Parameters

source
Type: System.Linq..::.ParallelQuery <(Of <(Nullable<(Of <(Int32>)>)>)>)
A sequence of values to calculate the sum of.

Return Value

The sum of the values in the sequence.

Exceptions

Exception | Condition
System..::.ArgumentNullException | source is a null reference (Nothing in Visual Basic).
System..::.AggregateException | The sum is larger than MaxValue()()(). -or- One or more exceptions occurred during the evaluation of the query.
System..::.OperationCanceledException | The query was canceled.

See Also

ParallelEnumerable Class
Sum Overload
System.Linq Namespace


Sum Method (ParallelQuery(Nullable(Int64)))

[image]

.NET Framework Class Library
ParallelEnumerable..::.Sum Method (ParallelQuery<(Of <(Nullable<(Of <(Int64>)>)>)>))
ParallelEnumerable Class See Also Send Feedback

Computes in parallel the sum of a sequence of values.

Namespace: System.Linq
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function Sum ( _
    source As ParallelQuery(Of Nullable(Of Long)) _
) As Nullable(Of Long)
C#
public static Nullable<long> Sum(
    ParallelQuery<Nullable<long>> source
)

Parameters

source
Type: System.Linq..::.ParallelQuery <(Of <(Nullable<(Of <(Int64>)>)>)>)
A sequence of values to calculate the sum of.

Return Value

The sum of the values in the sequence.

Exceptions

Exception | Condition
System..::.ArgumentNullException | source is a null reference (Nothing in Visual Basic).
System..::.AggregateException | The sum is larger than MaxValue()()(). -or- One or more exceptions occurred during the evaluation of the query.
System..::.OperationCanceledException | The query was canceled.

See Also

ParallelEnumerable Class
Sum Overload
System.Linq Namespace


Sum Method (ParallelQuery(Nullable(Single)))

[image]

.NET Framework Class Library
ParallelEnumerable..::.Sum Method (ParallelQuery<(Of <(Nullable<(Of <(Single>)>)>)>))
ParallelEnumerable Class See Also Send Feedback

Computes in parallel the sum of a sequence of values.

Namespace: System.Linq
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function Sum ( _
    source As ParallelQuery(Of Nullable(Of Single)) _
) As Nullable(Of Single)
C#
public static Nullable<float> Sum(
    ParallelQuery<Nullable<float>> source
)

Parameters

source
Type: System.Linq..::.ParallelQuery <(Of <(Nullable<(Of <(Single>)>)>)>)
A sequence of values to calculate the sum of.

Return Value

The sum of the values in the sequence.

Exceptions

Exception | Condition
System..::.ArgumentNullException | source is a null reference (Nothing in Visual Basic).
System..::.AggregateException | One or more exceptions occurred during the evaluation of the query.
System..::.OperationCanceledException | The query was canceled.

See Also

ParallelEnumerable Class
Sum Overload
System.Linq Namespace


Sum Method (ParallelQuery(Single))

[image]

.NET Framework Class Library
ParallelEnumerable..::.Sum Method (ParallelQuery<(Of <(Single>)>))
ParallelEnumerable Class See Also Send Feedback

Computes in parallel the sum of a sequence of values.

Namespace: System.Linq
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function Sum ( _
    source As ParallelQuery(Of Single) _
) As Single
C#
public static float Sum(
    ParallelQuery<float> source
)

Parameters

source
Type: System.Linq..::.ParallelQuery <(Of <(Single>)>)
A sequence of values to calculate the sum of.

Return Value

The sum of the values in the sequence.

Exceptions

Exception | Condition
System..::.ArgumentNullException | source is a null reference (Nothing in Visual Basic).
System..::.AggregateException | One or more exceptions occurred during the evaluation of the query.
System..::.OperationCanceledException | The query was canceled.

See Also

ParallelEnumerable Class
Sum Overload
System.Linq Namespace


Sum(TSource) Method (ParallelQuery(TSource), Func(TSource, Decimal))

[image]

.NET Framework Class Library
ParallelEnumerable..::.Sum<(Of <(TSource>)>) Method (ParallelQuery<(Of <(TSource>)>), Func<(Of <(TSource, Decimal>)>))
ParallelEnumerable Class See Also Send Feedback

Computes in parallel the sum of the sequence of values that are obtained by invoking a transform function on each element of the input sequence.

Namespace: System.Linq
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function Sum(Of TSource) ( _
    source As ParallelQuery(Of TSource), _
    selector As Func(Of TSource, Decimal) _
) As Decimal
C#
public static decimal Sum<TSource>(
    ParallelQuery<TSource> source,
    Func<TSource, decimal> selector
)

Parameters

source
Type: System.Linq..::.ParallelQuery <(Of <(TSource>)>)
A sequence of values to calculate the sum of.
selector
Type: System..::.Func<(Of <(TSource, Decimal>)>)
A transform function to apply to each element.

Type Parameters

TSource
The type of elements of source.

Return Value

The sum of the values in the sequence.

Exceptions

Exception | Condition
System..::.ArgumentNullException | source or selector is a null reference (Nothing in Visual Basic).
System..::.AggregateException | The sum is larger than MaxValue()()(). -or- One or more exceptions occurred during the evaluation of the query.
System..::.OperationCanceledException | The query was canceled.

See Also

ParallelEnumerable Class
Sum Overload
System.Linq Namespace


Sum(TSource) Method (ParallelQuery(TSource), Func(TSource, Double))

[image]

.NET Framework Class Library
ParallelEnumerable..::.Sum<(Of <(TSource>)>) Method (ParallelQuery<(Of <(TSource>)>), Func<(Of <(TSource, Double>)>))
ParallelEnumerable Class See Also Send Feedback

Computes in parallel the sum of the sequence of values that are obtained by invoking a transform function on each element of the input sequence.

Namespace: System.Linq
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function Sum(Of TSource) ( _
    source As ParallelQuery(Of TSource), _
    selector As Func(Of TSource, Double) _
) As Double
C#
public static double Sum<TSource>(
    ParallelQuery<TSource> source,
    Func<TSource, double> selector
)

Parameters

source
Type: System.Linq..::.ParallelQuery <(Of <(TSource>)>)
A sequence of values to calculate the sum of.
selector
Type: System..::.Func<(Of <(TSource, Double>)>)
A transform function to apply to each element.

Type Parameters

TSource
The type of elements of source.

Return Value

The sum of the values in the sequence.

Exceptions

Exception | Condition
System..::.ArgumentNullException | source or selector is a null reference (Nothing in Visual Basic).
System..::.AggregateException | One or more exceptions occurred during the evaluation of the query.
System..::.OperationCanceledException | The query was canceled.

See Also

ParallelEnumerable Class
Sum Overload
System.Linq Namespace


Sum(TSource) Method (ParallelQuery(TSource), Func(TSource, Int32))

[image]

.NET Framework Class Library
ParallelEnumerable..::.Sum<(Of <(TSource>)>) Method (ParallelQuery<(Of <(TSource>)>), Func<(Of <(TSource, Int32>)>))
ParallelEnumerable Class See Also Send Feedback

Computes in parallel the sum of the sequence of values that are obtained by invoking a transform function on each element of the input sequence.

Namespace: System.Linq
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function Sum(Of TSource) ( _
    source As ParallelQuery(Of TSource), _
    selector As Func(Of TSource, Integer) _
) As Integer
C#
public static int Sum<TSource>(
    ParallelQuery<TSource> source,
    Func<TSource, int> selector
)

Parameters

source
Type: System.Linq..::.ParallelQuery <(Of <(TSource>)>)
A sequence of values to calculate the sum of.
selector
Type: System..::.Func<(Of <(TSource, Int32>)>)
A transform function to apply to each element.

Type Parameters

TSource

Return Value

The sum of the values in the sequence.

Exceptions

Exception | Condition
System..::.ArgumentNullException | source or selector is a null reference (Nothing in Visual Basic).
System..::.AggregateException | The sum is larger than MaxValue()()(). -or- One or more exceptions occurred during the evaluation of the query.
System..::.OperationCanceledException | The query was canceled.

See Also

ParallelEnumerable Class
Sum Overload
System.Linq Namespace


Sum(TSource) Method (ParallelQuery(TSource), Func(TSource, Int64))

[image]

.NET Framework Class Library
ParallelEnumerable..::.Sum<(Of <(TSource>)>) Method (ParallelQuery<(Of <(TSource>)>), Func<(Of <(TSource, Int64>)>))
ParallelEnumerable Class See Also Send Feedback

Computes in parallel the sum of the sequence of values that are obtained by invoking a transform function on each element of the input sequence.

Namespace: System.Linq
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function Sum(Of TSource) ( _
    source As ParallelQuery(Of TSource), _
    selector As Func(Of TSource, Long) _
) As Long
C#
public static long Sum<TSource>(
    ParallelQuery<TSource> source,
    Func<TSource, long> selector
)

Parameters

source
Type: System.Linq..::.ParallelQuery <(Of <(TSource>)>)
A sequence of values to calculate the sum of.
selector
Type: System..::.Func<(Of <(TSource, Int64>)>)
A transform function to apply to each element.

Type Parameters

TSource
The type of elements of source.

Return Value

The sum of the values in the sequence.

Exceptions

Exception | Condition
System..::.ArgumentNullException | source or selector is a null reference (Nothing in Visual Basic).
System..::.AggregateException | The sum is larger than MaxValue()()(). -or- One or more exceptions occurred during the evaluation of the query.
System..::.OperationCanceledException | The query was canceled.

See Also

ParallelEnumerable Class
Sum Overload
System.Linq Namespace


Sum(TSource) Method (ParallelQuery(TSource), Func(TSource, Nullable(Decimal)))

[image]

.NET Framework Class Library
ParallelEnumerable..::.Sum<(Of <(TSource>)>) Method (ParallelQuery<(Of <(TSource>)>), Func<(Of <(TSource, Nullable<(Of <(Decimal>)>)>)>))
ParallelEnumerable Class See Also Send Feedback

Computes in parallel the sum of the sequence of values that are obtained by invoking a transform function on each element of the input sequence.

Namespace: System.Linq
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function Sum(Of TSource) ( _
    source As ParallelQuery(Of TSource), _
    selector As Func(Of TSource, Nullable(Of Decimal)) _
) As Nullable(Of Decimal)
C#
public static Nullable<decimal> Sum<TSource>(
    ParallelQuery<TSource> source,
    Func<TSource, Nullable<decimal>> selector
)

Parameters

source
Type: System.Linq..::.ParallelQuery <(Of <(TSource>)>)
A sequence of values to calculate the sum of.
selector
Type: System..::.Func<(Of <(TSource, Nullable<(Of <(Decimal>)>)>)>)
A transform function to apply to each element.

Type Parameters

TSource
The type of elements of source.

Return Value

The sum of the values in the sequence.

Exceptions

Exception | Condition
System..::.ArgumentNullException | source or selector is a null reference (Nothing in Visual Basic).
System..::.AggregateException | The sum is larger than MaxValue()()(). -or- One or more exceptions occurred during the evaluation of the query.
System..::.OperationCanceledException | The query was canceled.

See Also

ParallelEnumerable Class
Sum Overload
System.Linq Namespace


Sum(TSource) Method (ParallelQuery(TSource), Func(TSource, Nullable(Double)))

[image]

.NET Framework Class Library
ParallelEnumerable..::.Sum<(Of <(TSource>)>) Method (ParallelQuery<(Of <(TSource>)>), Func<(Of <(TSource, Nullable<(Of <(Double>)>)>)>))
ParallelEnumerable Class See Also Send Feedback

Computes in parallel the sum of the sequence of values that are obtained by invoking a transform function on each element of the input sequence.

Namespace: System.Linq
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function Sum(Of TSource) ( _
    source As ParallelQuery(Of TSource), _
    selector As Func(Of TSource, Nullable(Of Double)) _
) As Nullable(Of Double)
C#
public static Nullable<double> Sum<TSource>(
    ParallelQuery<TSource> source,
    Func<TSource, Nullable<double>> selector
)

Parameters

source
Type: System.Linq..::.ParallelQuery <(Of <(TSource>)>)
A sequence of values to calculate the sum of.
selector
Type: System..::.Func<(Of <(TSource, Nullable<(Of <(Double>)>)>)>)
A transform function to apply to each element.

Type Parameters

TSource
The type of elements of source.

Return Value

The sum of the values in the sequence.

Exceptions

Exception | Condition
System..::.ArgumentNullException | source or selector is a null reference (Nothing in Visual Basic).
System..::.AggregateException | One or more exceptions occurred during the evaluation of the query.
System..::.OperationCanceledException | The query was canceled.

See Also

ParallelEnumerable Class
Sum Overload
System.Linq Namespace


Sum(TSource) Method (ParallelQuery(TSource), Func(TSource, Nullable(Int32)))

[image]

.NET Framework Class Library
ParallelEnumerable..::.Sum<(Of <(TSource>)>) Method (ParallelQuery<(Of <(TSource>)>), Func<(Of <(TSource, Nullable<(Of <(Int32>)>)>)>))
ParallelEnumerable Class See Also Send Feedback

Computes in parallel the sum of the sequence of values that are obtained by invoking a transform function on each element of the input sequence.

Namespace: System.Linq
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function Sum(Of TSource) ( _
    source As ParallelQuery(Of TSource), _
    selector As Func(Of TSource, Nullable(Of Integer)) _
) As Nullable(Of Integer)
C#
public static Nullable<int> Sum<TSource>(
    ParallelQuery<TSource> source,
    Func<TSource, Nullable<int>> selector
)

Parameters

source
Type: System.Linq..::.ParallelQuery <(Of <(TSource>)>)
A sequence of values to calculate the sum of.
selector
Type: System..::.Func<(Of <(TSource, Nullable<(Of <(Int32>)>)>)>)
A transform function to apply to each element.

Type Parameters

TSource
The type of elements of source.

Return Value

The sum of the values in the sequence.

Exceptions

Exception | Condition
System..::.ArgumentNullException | source or selector is a null reference (Nothing in Visual Basic).
System..::.AggregateException | The sum is larger than MaxValue()()(). -or- One or more exceptions occurred during the evaluation of the query.
System..::.OperationCanceledException | The query was canceled.

See Also

ParallelEnumerable Class
Sum Overload
System.Linq Namespace


Sum(TSource) Method (ParallelQuery(TSource), Func(TSource, Nullable(Int64)))

[image]

.NET Framework Class Library
ParallelEnumerable..::.Sum<(Of <(TSource>)>) Method (ParallelQuery<(Of <(TSource>)>), Func<(Of <(TSource, Nullable<(Of <(Int64>)>)>)>))
ParallelEnumerable Class See Also Send Feedback

Computes in parallel the sum of the sequence of values that are obtained by invoking a transform function on each element of the input sequence.

Namespace: System.Linq
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function Sum(Of TSource) ( _
    source As ParallelQuery(Of TSource), _
    selector As Func(Of TSource, Nullable(Of Long)) _
) As Nullable(Of Long)
C#
public static Nullable<long> Sum<TSource>(
    ParallelQuery<TSource> source,
    Func<TSource, Nullable<long>> selector
)

Parameters

source
Type: System.Linq..::.ParallelQuery <(Of <(TSource>)>)
A sequence of values to calculate the sum of.
selector
Type: System..::.Func<(Of <(TSource, Nullable<(Of <(Int64>)>)>)>)
A transform function to apply to each element.

Type Parameters

TSource
The type of elements of source.

Return Value

The sum of the values in the sequence.

Exceptions

Exception | Condition
System..::.ArgumentNullException | source or selector is a null reference (Nothing in Visual Basic).
System..::.AggregateException | The sum is larger than MaxValue()()(). -or- One or more exceptions occurred during the evaluation of the query.
System..::.OperationCanceledException | The query was canceled.

See Also

ParallelEnumerable Class
Sum Overload
System.Linq Namespace


Sum(TSource) Method (ParallelQuery(TSource), Func(TSource, Nullable(Single)))

[image]

.NET Framework Class Library
ParallelEnumerable..::.Sum<(Of <(TSource>)>) Method (ParallelQuery<(Of <(TSource>)>), Func<(Of <(TSource, Nullable<(Of <(Single>)>)>)>))
ParallelEnumerable Class See Also Send Feedback

Computes in parallel the sum of the sequence of values that are obtained by invoking a transform function on each element of the input sequence.

Namespace: System.Linq
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function Sum(Of TSource) ( _
    source As ParallelQuery(Of TSource), _
    selector As Func(Of TSource, Nullable(Of Single)) _
) As Nullable(Of Single)
C#
public static Nullable<float> Sum<TSource>(
    ParallelQuery<TSource> source,
    Func<TSource, Nullable<float>> selector
)

Parameters

source
Type: System.Linq..::.ParallelQuery <(Of <(TSource>)>)
A sequence of values to calculate the sum of.
selector
Type: System..::.Func<(Of <(TSource, Nullable<(Of <(Single>)>)>)>)
A transform function to apply to each element.

Type Parameters

TSource
The type of elements of source.

Return Value

The sum of the values in the sequence.

Exceptions

Exception | Condition
System..::.ArgumentNullException | source or selector is a null reference (Nothing in Visual Basic).
System..::.AggregateException | One or more exceptions occurred during the evaluation of the query.
System..::.OperationCanceledException | The query was canceled.

See Also

ParallelEnumerable Class
Sum Overload
System.Linq Namespace


Sum(TSource) Method (ParallelQuery(TSource), Func(TSource, Single))

[image]

.NET Framework Class Library
ParallelEnumerable..::.Sum<(Of <(TSource>)>) Method (ParallelQuery<(Of <(TSource>)>), Func<(Of <(TSource, Single>)>))
ParallelEnumerable Class See Also Send Feedback

Computes in parallel the sum of the sequence of values that are obtained by invoking a transform function on each element of the input sequence.

Namespace: System.Linq
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function Sum(Of TSource) ( _
    source As ParallelQuery(Of TSource), _
    selector As Func(Of TSource, Single) _
) As Single
C#
public static float Sum<TSource>(
    ParallelQuery<TSource> source,
    Func<TSource, float> selector
)

Parameters

source
Type: System.Linq..::.ParallelQuery <(Of <(TSource>)>)
A sequence of values to calculate the sum of.
selector
Type: System..::.Func<(Of <(TSource, Single>)>)
A transform function to apply to each element.

Type Parameters

TSource
The type of elements of source.

Return Value

The sum of the values in the sequence.

Exceptions

Exception | Condition
System..::.ArgumentNullException | source or selector is a null reference (Nothing in Visual Basic).
System..::.AggregateException | One or more exceptions occurred during the evaluation of the query.
System..::.OperationCanceledException | The query was canceled.

See Also

ParallelEnumerable Class
Sum Overload
System.Linq Namespace


Take(TSource) Method

[image]

.NET Framework Class Library
ParallelEnumerable..::.Take<(Of <(TSource>)>) Method
ParallelEnumerable Class See Also Send Feedback

Returns a specified number of contiguous elements from the start of a parallel sequence.

Namespace: System.Linq
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function Take(Of TSource) ( _
    source As ParallelQuery(Of TSource), _
    count As Integer _
) As ParallelQuery(Of TSource)
C#
public static ParallelQuery<TSource> Take<TSource>(
    ParallelQuery<TSource> source,
    int count
)

Parameters

source
Type: System.Linq..::.ParallelQuery <(Of <(TSource>)>)
The sequence to return elements from.
count
Type: System..::.Int32
The number of elements to return.

Type Parameters

TSource
The type of elements of source.

Return Value

A sequence that contains the specified number of elements from the start of the input sequence.

Exceptions

Exception | Condition
System..::.ArgumentNullException | source is a null reference (Nothing in Visual Basic).

See Also

ParallelEnumerable Class
System.Linq Namespace


TakeWhile Method

[image] [image]

.NET Framework Class Library
ParallelEnumerable..::.TakeWhile Method
ParallelEnumerable Class See Also Send Feedback

Overload List

Name | Description
TakeWhile<(Of <(TSource>)>)(ParallelQuery<(Of <(TSource>)>), Func<(Of <(TSource, Boolean>)>)) | Returns elements from a parallel sequence as long as a specified condition is true.
TakeWhile<(Of <(TSource>)>)(ParallelQuery<(Of <(TSource>)>), Func<(Of <(TSource, Int32, Boolean>)>)) | Returns elements from a parallel sequence as long as a specified condition is true. The element's index is used in the logic of the predicate function.

See Also

ParallelEnumerable Class
System.Linq Namespace


TakeWhile(TSource) Method (ParallelQuery(TSource), Func(TSource, Boolean))

[image]

.NET Framework Class Library
ParallelEnumerable..::.TakeWhile<(Of <(TSource>)>) Method (ParallelQuery<(Of <(TSource>)>), Func<(Of <(TSource, Boolean>)>))
ParallelEnumerable Class See Also Send Feedback

Returns elements from a parallel sequence as long as a specified condition is true.

Namespace: System.Linq
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function TakeWhile(Of TSource) ( _
    source As ParallelQuery(Of TSource), _
    predicate As Func(Of TSource, Boolean) _
) As ParallelQuery(Of TSource)
C#
public static ParallelQuery<TSource> TakeWhile<TSource>(
    ParallelQuery<TSource> source,
    Func<TSource, bool> predicate
)

Parameters

source
Type: System.Linq..::.ParallelQuery <(Of <(TSource>)>)
The sequence to return elements from.
predicate
Type: System..::.Func<(Of <(TSource, Boolean>)>)
A function to test each element for a condition.

Type Parameters

TSource
The type of elements of source.

Return Value

A sequence that contains the elements from the input sequence that occur before the element at which the test no longer passes.

Exceptions

Exception | Condition
System..::.ArgumentNullException | source or predicate is a null reference (Nothing in Visual Basic).

See Also

ParallelEnumerable Class
TakeWhile Overload
System.Linq Namespace


TakeWhile(TSource) Method (ParallelQuery(TSource), Func(TSource, Int32, Boolean))

[image]

.NET Framework Class Library
ParallelEnumerable..::.TakeWhile<(Of <(TSource>)>) Method (ParallelQuery<(Of <(TSource>)>), Func<(Of <(TSource, Int32, Boolean>)>))
ParallelEnumerable Class See Also Send Feedback

Returns elements from a parallel sequence as long as a specified condition is true. The element's index is used in the logic of the predicate function.

Namespace: System.Linq
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function TakeWhile(Of TSource) ( _
    source As ParallelQuery(Of TSource), _
    predicate As Func(Of TSource, Integer, Boolean) _
) As ParallelQuery(Of TSource)
C#
public static ParallelQuery<TSource> TakeWhile<TSource>(
    ParallelQuery<TSource> source,
    Func<TSource, int, bool> predicate
)

Parameters

source
Type: System.Linq..::.ParallelQuery <(Of <(TSource>)>)
The sequence to return elements from.
predicate
Type: System..::.Func<(Of <(TSource, Int32, Boolean>)>)
A function to test each source element for a condition; the second parameter of the function represents the index of the source element.

Type Parameters

TSource
The type of elements of source.

Return Value

A sequence that contains elements from the input sequence that occur before the element at which the test no longer passes.

Exceptions

Exception | Condition
System..::.ArgumentNullException | source or predicate is a null reference (Nothing in Visual Basic).

See Also

ParallelEnumerable Class
TakeWhile Overload
System.Linq Namespace


ThenBy Method

[image] [image]

.NET Framework Class Library
ParallelEnumerable..::.ThenBy Method
ParallelEnumerable Class See Also Send Feedback

Overload List

Name | Description
ThenBy<(Of <(TSource, TKey>)>)(OrderedParallelQuery<(Of <(TSource>)>), Func<(Of <(TSource, TKey>)>)) | Performs in parallel a subsequent ordering of the elements in a sequence in ascending order according to a key.
ThenBy<(Of <(TSource, TKey>)>)(OrderedParallelQuery<(Of <(TSource>)>), Func<(Of <(TSource, TKey>)>), IComparer<(Of <(TKey>)>)) | Performs in parallel a subsequent ordering of the elements in a sequence in ascending order by using a specified comparer.

See Also

ParallelEnumerable Class
System.Linq Namespace


ThenBy(TSource, TKey) Method (OrderedParallelQuery(TSource), Func(TSource, TKey))

[image]

.NET Framework Class Library
ParallelEnumerable..::.ThenBy<(Of <(TSource, TKey>)>) Method (OrderedParallelQuery<(Of <(TSource>)>), Func<(Of <(TSource, TKey>)>))
ParallelEnumerable Class See Also Send Feedback

Performs in parallel a subsequent ordering of the elements in a sequence in ascending order according to a key.

Namespace: System.Linq
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function ThenBy(Of TSource, TKey) ( _
    source As OrderedParallelQuery(Of TSource), _
    keySelector As Func(Of TSource, TKey) _
) As OrderedParallelQuery(Of TSource)
C#
public static OrderedParallelQuery<TSource> ThenBy<TSource, TKey>(
    OrderedParallelQuery<TSource> source,
    Func<TSource, TKey> keySelector
)

Parameters

source
Type: System.Linq..::.OrderedParallelQuery <(Of <(TSource>)>)
An OrderedParallelQuery{TSource} than contains elements to sort.
keySelector
Type: System..::.Func<(Of <(TSource, TKey>)>)
A function to extract a key from an element.

Type Parameters

TSource
The type of elements of source.
TKey
The type of the key returned by keySelector.

Return Value

An OrderedParallelQuery{TSource} whose elements are sorted according to a key.

Remarks

In contrast to the sequential implementation, this is not a stable sort. See the remarks for OrderBy(ParallelQuery{TSource}, Func{TSource,TKey}) for an approach to implementing a stable sort.

Exceptions

Exception | Condition
System..::.ArgumentNullException | source or keySelector is a null reference (Nothing in Visual Basic).

See Also

ParallelEnumerable Class
ThenBy Overload
System.Linq Namespace


ThenBy(TSource, TKey) Method (OrderedParallelQuery(TSource), Func(TSource, TKey), IComparer(TKey))

[image]

.NET Framework Class Library
ParallelEnumerable..::.ThenBy<(Of <(TSource, TKey>)>) Method (OrderedParallelQuery<(Of <(TSource>)>), Func<(Of <(TSource, TKey>)>), IComparer<(Of <(TKey>)>))
ParallelEnumerable Class See Also Send Feedback

Performs in parallel a subsequent ordering of the elements in a sequence in ascending order by using a specified comparer.

Namespace: System.Linq
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function ThenBy(Of TSource, TKey) ( _
    source As OrderedParallelQuery(Of TSource), _
    keySelector As Func(Of TSource, TKey), _
    comparer As IComparer(Of TKey) _
) As OrderedParallelQuery(Of TSource)
C#
public static OrderedParallelQuery<TSource> ThenBy<TSource, TKey>(
    OrderedParallelQuery<TSource> source,
    Func<TSource, TKey> keySelector,
    IComparer<TKey> comparer
)

Parameters

source
Type: System.Linq..::.OrderedParallelQuery <(Of <(TSource>)>)
An OrderedParallelQuery{TSource} that contains elements to sort.
keySelector
Type: System..::.Func<(Of <(TSource, TKey>)>)
A function to extract a key from an element.
comparer
Type: System.Collections.Generic..::.IComparer<(Of <(TKey>)>)
An IComparer{TKey} to compare keys.

Type Parameters

TSource
The type of elements of source.
TKey
The type of the key returned by keySelector.

Return Value

An OrderedParallelQuery{TSource} whose elements are sorted according to a key.

Remarks

In contrast to the sequential implementation, this is not a stable sort. See the remarks for OrderBy(ParallelQuery{TSource}, Func{TSource,TKey}) for an approach to implementing a stable sort.

Exceptions

Exception | Condition
System..::.ArgumentNullException | source or keySelector is a null reference (Nothing in Visual Basic).

See Also

ParallelEnumerable Class
ThenBy Overload
System.Linq Namespace


ThenByDescending Method

[image] [image]

.NET Framework Class Library
ParallelEnumerable..::.ThenByDescending Method
ParallelEnumerable Class See Also Send Feedback

Overload List

Name | Description
ThenByDescending<(Of <(TSource, TKey>)>)(OrderedParallelQuery<(Of <(TSource>)>), Func<(Of <(TSource, TKey>)>)) | Performs in parallel a subsequent ordering of the elements in a sequence in descending order, according to a key.
ThenByDescending<(Of <(TSource, TKey>)>)(OrderedParallelQuery<(Of <(TSource>)>), Func<(Of <(TSource, TKey>)>), IComparer<(Of <(TKey>)>)) | Performs in parallel a subsequent ordering of the elements in a sequence in descending order by using a specified comparer.

See Also

ParallelEnumerable Class
System.Linq Namespace


ThenByDescending(TSource, TKey) Method (OrderedParallelQuery(TSource), Func(TSource, TKey))

[image]

.NET Framework Class Library
ParallelEnumerable..::.ThenByDescending<(Of <(TSource, TKey>)>) Method (OrderedParallelQuery<(Of <(TSource>)>), Func<(Of <(TSource, TKey>)>))
ParallelEnumerable Class See Also Send Feedback

Performs in parallel a subsequent ordering of the elements in a sequence in descending order, according to a key.

Namespace: System.Linq
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function ThenByDescending(Of TSource, TKey) ( _
    source As OrderedParallelQuery(Of TSource), _
    keySelector As Func(Of TSource, TKey) _
) As OrderedParallelQuery(Of TSource)
C#
public static OrderedParallelQuery<TSource> ThenByDescending<TSource, TKey>(
    OrderedParallelQuery<TSource> source,
    Func<TSource, TKey> keySelector
)

Parameters

source
Type: System.Linq..::.OrderedParallelQuery <(Of <(TSource>)>)
An OrderedParallelQuery{TSource} than contains elements to sort.
keySelector
Type: System..::.Func<(Of <(TSource, TKey>)>)
A function to extract a key from an element.

Type Parameters

TSource
The type of elements of source.
TKey
The type of the key returned by keySelector.

Return Value

An OrderedParallelQuery{TSource} whose elements are sorted descending according to a key.

Remarks

In contrast to the sequential implementation, this is not a stable sort. See the remarks for OrderBy(ParallelQuery{TSource}, Func{TSource,TKey}) for an approach to implementing a stable sort.

Exceptions

Exception | Condition
System..::.ArgumentNullException | source or keySelector is a null reference (Nothing in Visual Basic).

See Also

ParallelEnumerable Class
ThenByDescending Overload
System.Linq Namespace


ThenByDescending(TSource, TKey) Method (OrderedParallelQuery(TSource), Func(TSource, TKey), IComparer(TKey))

[image]

.NET Framework Class Library
ParallelEnumerable..::.ThenByDescending<(Of <(TSource, TKey>)>) Method (OrderedParallelQuery<(Of <(TSource>)>), Func<(Of <(TSource, TKey>)>), IComparer<(Of <(TKey>)>))
ParallelEnumerable Class See Also Send Feedback

Performs in parallel a subsequent ordering of the elements in a sequence in descending order by using a specified comparer.

Namespace: System.Linq
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function ThenByDescending(Of TSource, TKey) ( _
    source As OrderedParallelQuery(Of TSource), _
    keySelector As Func(Of TSource, TKey), _
    comparer As IComparer(Of TKey) _
) As OrderedParallelQuery(Of TSource)
C#
public static OrderedParallelQuery<TSource> ThenByDescending<TSource, TKey>(
    OrderedParallelQuery<TSource> source,
    Func<TSource, TKey> keySelector,
    IComparer<TKey> comparer
)

Parameters

source
Type: System.Linq..::.OrderedParallelQuery <(Of <(TSource>)>)
An OrderedParallelQuery{TSource} than contains elements to sort.
keySelector
Type: System..::.Func<(Of <(TSource, TKey>)>)
A function to extract a key from an element.
comparer
Type: System.Collections.Generic..::.IComparer<(Of <(TKey>)>)
An IComparer{TKey} to compare keys.

Type Parameters

TSource
The type of elements of source.
TKey
The type of the key returned by keySelector.

Return Value

An OrderedParallelQuery{TSource} whose elements are sorted descending according to a key.

Remarks

In contrast to the sequential implementation, this is not a stable sort. See the remarks for OrderBy(ParallelQuery{TSource}, Func{TSource,TKey}) for an approach to implementing a stable sort.

Exceptions

Exception | Condition
System..::.ArgumentNullException | source or keySelector is a null reference (Nothing in Visual Basic).

See Also

ParallelEnumerable Class
ThenByDescending Overload
System.Linq Namespace


ToArray(TSource) Method

[image]

.NET Framework Class Library
ParallelEnumerable..::.ToArray<(Of <(TSource>)>) Method
ParallelEnumerable Class See Also Send Feedback

Creates an array from a ParallelQuery{T}.

Namespace: System.Linq
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function ToArray(Of TSource) ( _
    source As ParallelQuery(Of TSource) _
) As TSource()
C#
public static TSource[] ToArray<TSource>(
    ParallelQuery<TSource> source
)

Parameters

source
Type: System.Linq..::.ParallelQuery <(Of <(TSource>)>)
A sequence to create an array from.

Type Parameters

TSource
The type of the elements of source.

Return Value

An array that contains the elements from the input sequence.

Exceptions

Exception | Condition
System..::.ArgumentNullException | source is a null reference (Nothing in Visual Basic).
System..::.AggregateException | One or more exceptions occurred during the evaluation of the query.
System..::.OperationCanceledException | The query was canceled.

See Also

ParallelEnumerable Class
System.Linq Namespace


ToDictionary Method

[image] [image]

.NET Framework Class Library
ParallelEnumerable..::.ToDictionary Method
ParallelEnumerable Class See Also Send Feedback

Overload List

Name | Description
ToDictionary<(Of <(TSource, TKey>)>)(ParallelQuery<(Of <(TSource>)>), Func<(Of <(TSource, TKey>)>)) | Creates a Dictionary{TKey,TValue} from a ParallelQuery{T} according to a specified key selector function.
ToDictionary<(Of <(TSource, TKey>)>)(ParallelQuery<(Of <(TSource>)>), Func<(Of <(TSource, TKey>)>), IEqualityComparer<(Of <(TKey>)>)) | Creates a Dictionary{TKey,TValue} from a ParallelQuery{T} according to a specified key selector function and key comparer.
ToDictionary<(Of <(TSource, TKey, TElement>)>)(ParallelQuery<(Of <(TSource>)>), Func<(Of <(TSource, TKey>)>), Func<(Of <(TSource, TElement>)>)) | Creates a Dictionary{TKey,TValue} from a ParallelQuery{T} according to specified key selector and element selector functions.
ToDictionary<(Of <(TSource, TKey, TElement>)>)(ParallelQuery<(Of <(TSource>)>), Func<(Of <(TSource, TKey>)>), Func<(Of <(TSource, TElement>)>), IEqualityComparer<(Of <(TKey>)>)) | Creates a Dictionary{TKey,TValue from a ParallelQuery{T} according to a specified key selector function, a comparer, and an element selector function.

See Also

ParallelEnumerable Class
System.Linq Namespace


ToDictionary(TSource, TKey) Method (ParallelQuery(TSource), Func(TSource, TKey))

[image]

.NET Framework Class Library
ParallelEnumerable..::.ToDictionary<(Of <(TSource, TKey>)>) Method (ParallelQuery<(Of <(TSource>)>), Func<(Of <(TSource, TKey>)>))
ParallelEnumerable Class See Also Send Feedback

Creates a Dictionary{TKey,TValue} from a ParallelQuery{T} according to a specified key selector function.

Namespace: System.Linq
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function ToDictionary(Of TSource, TKey) ( _
    source As ParallelQuery(Of TSource), _
    keySelector As Func(Of TSource, TKey) _
) As Dictionary(Of TKey, TSource)
C#
public static Dictionary<TKey, TSource> ToDictionary<TSource, TKey>(
    ParallelQuery<TSource> source,
    Func<TSource, TKey> keySelector
)

Parameters

source
Type: System.Linq..::.ParallelQuery <(Of <(TSource>)>)
A sequence to create a Dictionary<(Of <(TKey, TValue>)>) from.
keySelector
Type: System..::.Func<(Of <(TSource, TKey>)>)
A function to extract a key from each element.

Type Parameters

TSource
The type of the elements of source.
TKey
The type of the key returned by keySelector.

Return Value

A Dictionary<(Of <(TKey, TValue>)>) that contains keys and values.

Exceptions

Exception | Condition
System..::.ArgumentNullException | source or keySelector is a null reference (Nothing in Visual Basic).
System..::.AggregateException | keySelector produces a key that is a null reference (Nothing in Visual Basic). -or- keySelector produces duplicate keys for two elements. -or- One or more exceptions occurred during the evaluation of the query.
System..::.OperationCanceledException | The query was canceled.

See Also

ParallelEnumerable Class
ToDictionary Overload
System.Linq Namespace


ToDictionary(TSource, TKey) Method (ParallelQuery(TSource), Func(TSource, TKey), IEqualityComparer(TKey))

[image]

.NET Framework Class Library
ParallelEnumerable..::.ToDictionary<(Of <(TSource, TKey>)>) Method (ParallelQuery<(Of <(TSource>)>), Func<(Of <(TSource, TKey>)>), IEqualityComparer<(Of <(TKey>)>))
ParallelEnumerable Class See Also Send Feedback

Creates a Dictionary{TKey,TValue} from a ParallelQuery{T} according to a specified key selector function and key comparer.

Namespace: System.Linq
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function ToDictionary(Of TSource, TKey) ( _
    source As ParallelQuery(Of TSource), _
    keySelector As Func(Of TSource, TKey), _
    comparer As IEqualityComparer(Of TKey) _
) As Dictionary(Of TKey, TSource)
C#
public static Dictionary<TKey, TSource> ToDictionary<TSource, TKey>(
    ParallelQuery<TSource> source,
    Func<TSource, TKey> keySelector,
    IEqualityComparer<TKey> comparer
)

Parameters

source
Type: System.Linq..::.ParallelQuery <(Of <(TSource>)>)
A sequence to create a Dictionary<(Of <(TKey, TValue>)>) from.
keySelector
Type: System..::.Func<(Of <(TSource, TKey>)>)
A function to extract a key from each element.
comparer
Type: System.Collections.Generic..::.IEqualityComparer<(Of <(TKey>)>)
An IEqualityComparer<(Of <(T>)>) to compare keys.

Type Parameters

TSource
The type of the elements of source.
TKey
The type of the key returned by keySelector.

Return Value

A Dictionary<(Of <(TKey, TValue>)>) that contains keys and values.

Exceptions

Exception | Condition
System..::.ArgumentNullException | source or keySelector is a null reference (Nothing in Visual Basic).
System..::.AggregateException | keySelector produces a key that is a null reference (Nothing in Visual Basic). -or- keySelector produces duplicate keys for two elements. -or- One or more exceptions occurred during the evaluation of the query.
System..::.OperationCanceledException | The query was canceled.

See Also

ParallelEnumerable Class
ToDictionary Overload
System.Linq Namespace


ToDictionary(TSource, TKey, TElement) Method (ParallelQuery(TSource), Func(TSource, TKey), Func(TSource, TElement))

[image]

.NET Framework Class Library
ParallelEnumerable..::.ToDictionary<(Of <(TSource, TKey, TElement>)>) Method (ParallelQuery<(Of <(TSource>)>), Func<(Of <(TSource, TKey>)>), Func<(Of <(TSource, TElement>)>))
ParallelEnumerable Class See Also Send Feedback

Creates a Dictionary{TKey,TValue} from a ParallelQuery{T} according to specified key selector and element selector functions.

Namespace: System.Linq
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function ToDictionary(Of TSource, TKey, TElement) ( _
    source As ParallelQuery(Of TSource), _
    keySelector As Func(Of TSource, TKey), _
    elementSelector As Func(Of TSource, TElement) _
) As Dictionary(Of TKey, TElement)
C#
public static Dictionary<TKey, TElement> ToDictionary<TSource, TKey, TElement>(
    ParallelQuery<TSource> source,
    Func<TSource, TKey> keySelector,
    Func<TSource, TElement> elementSelector
)

Parameters

source
Type: System.Linq..::.ParallelQuery <(Of <(TSource>)>)
A sequence to create a Dictionary<(Of <(TKey, TValue>)>) from.
keySelector
Type: System..::.Func<(Of <(TSource, TKey>)>)
A function to extract a key from each element.
elementSelector
Type: System..::.Func<(Of <(TSource, TElement>)>)
A transform function to produce a result element value from each element.

Type Parameters

TSource
The type of the elements of source.
TKey
The type of the key returned by keySelector.
TElement
The type of the value returned by elementSelector.

Return Value

A Dictionary<(Of <(TKey, TValue>)>) that contains values of type TElement selected from the input sequence

Exceptions

Exception | Condition
System..::.ArgumentNullException | source or keySelector or elementSelector is a null reference (Nothing in Visual Basic).
System..::.AggregateException | keySelector produces a key that is a null reference (Nothing in Visual Basic). -or- keySelector produces duplicate keys for two elements. -or- One or more exceptions occurred during the evaluation of the query.
System..::.OperationCanceledException | The query was canceled.

See Also

ParallelEnumerable Class
ToDictionary Overload
System.Linq Namespace


ToDictionary(TSource, TKey, TElement) Method (ParallelQuery(TSource), Func(TSource, TKey), Func(TSource, TElement), IEqualityComparer(TKey))

[image]

.NET Framework Class Library
ParallelEnumerable..::.ToDictionary<(Of <(TSource, TKey, TElement>)>) Method (ParallelQuery<(Of <(TSource>)>), Func<(Of <(TSource, TKey>)>), Func<(Of <(TSource, TElement>)>), IEqualityComparer<(Of <(TKey>)>))
ParallelEnumerable Class See Also Send Feedback

Creates a Dictionary{TKey,TValue from a ParallelQuery{T} according to a specified key selector function, a comparer, and an element selector function.

Namespace: System.Linq
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function ToDictionary(Of TSource, TKey, TElement) ( _
    source As ParallelQuery(Of TSource), _
    keySelector As Func(Of TSource, TKey), _
    elementSelector As Func(Of TSource, TElement), _
    comparer As IEqualityComparer(Of TKey) _
) As Dictionary(Of TKey, TElement)
C#
public static Dictionary<TKey, TElement> ToDictionary<TSource, TKey, TElement>(
    ParallelQuery<TSource> source,
    Func<TSource, TKey> keySelector,
    Func<TSource, TElement> elementSelector,
    IEqualityComparer<TKey> comparer
)

Parameters

source
Type: System.Linq..::.ParallelQuery <(Of <(TSource>)>)
A sequence to create a Dictionary<(Of <(TKey, TValue>)>) from.
keySelector
Type: System..::.Func<(Of <(TSource, TKey>)>)
A function to extract a key from each element.
elementSelector
Type: System..::.Func<(Of <(TSource, TElement>)>)
A transform function to produce a result element value from each element.
comparer
Type: System.Collections.Generic..::.IEqualityComparer<(Of <(TKey>)>)
An IEqualityComparer<(Of <(T>)>) to compare keys.

Type Parameters

TSource
The type of the elements of source.
TKey
The type of the key returned by keySelector.
TElement
The type of the value returned by elementSelector.

Return Value

A Dictionary<(Of <(TKey, TValue>)>) that contains values of type TElement selected from the input sequence

Exceptions

Exception | Condition
System..::.ArgumentNullException | source or keySelector or elementSelector is a null reference (Nothing in Visual Basic).
System..::.AggregateException | keySelector produces a key that is a null reference (Nothing in Visual Basic). -or- keySelector produces duplicate keys for two elements. -or- One or more exceptions occurred during the evaluation of the query.
System..::.OperationCanceledException | The query was canceled.

See Also

ParallelEnumerable Class
ToDictionary Overload
System.Linq Namespace


ToList(TSource) Method

[image]

.NET Framework Class Library
ParallelEnumerable..::.ToList<(Of <(TSource>)>) Method
ParallelEnumerable Class See Also Send Feedback

Creates a List{T} from an ParallelQuery{T}.

Namespace: System.Linq
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function ToList(Of TSource) ( _
    source As ParallelQuery(Of TSource) _
) As List(Of TSource)
C#
public static List<TSource> ToList<TSource>(
    ParallelQuery<TSource> source
)

Parameters

source
Type: System.Linq..::.ParallelQuery <(Of <(TSource>)>)
A sequence to create a List<(Of <(T>)>) from.

Type Parameters

TSource
The type of the elements of source.

Return Value

A List<(Of <(T>)>) that contains elements from the input sequence.

Exceptions

Exception | Condition
System..::.ArgumentNullException | source is a null reference (Nothing in Visual Basic).
System..::.AggregateException | One or more exceptions occurred during the evaluation of the query.
System..::.OperationCanceledException | The query was canceled.

See Also

ParallelEnumerable Class
System.Linq Namespace


ToLookup Method

[image] [image]

.NET Framework Class Library
ParallelEnumerable..::.ToLookup Method
ParallelEnumerable Class See Also Send Feedback

Overload List

Name | Description
ToLookup<(Of <(TSource, TKey>)>)(ParallelQuery<(Of <(TSource>)>), Func<(Of <(TSource, TKey>)>)) | Creates an ILookup{TKey,T} from a ParallelQuery{T} according to a specified key selector function.
ToLookup<(Of <(TSource, TKey>)>)(ParallelQuery<(Of <(TSource>)>), Func<(Of <(TSource, TKey>)>), IEqualityComparer<(Of <(TKey>)>)) | Creates an ILookup{TKey,T} from a ParallelQuery{T} according to a specified key selector function and key comparer.
ToLookup<(Of <(TSource, TKey, TElement>)>)(ParallelQuery<(Of <(TSource>)>), Func<(Of <(TSource, TKey>)>), Func<(Of <(TSource, TElement>)>)) | Creates an ILookup{TKey,TElement} from a ParallelQuery{T} according to specified key selector and element selector functions.
ToLookup<(Of <(TSource, TKey, TElement>)>)(ParallelQuery<(Of <(TSource>)>), Func<(Of <(TSource, TKey>)>), Func<(Of <(TSource, TElement>)>), IEqualityComparer<(Of <(TKey>)>)) | Creates an ILookup{TKey,TElement} from a ParallelQuery{T} according to a specified key selector function, a comparer and an element selector function.

See Also

ParallelEnumerable Class
System.Linq Namespace


ToLookup(TSource, TKey) Method (ParallelQuery(TSource), Func(TSource, TKey))

[image]

.NET Framework Class Library
ParallelEnumerable..::.ToLookup<(Of <(TSource, TKey>)>) Method (ParallelQuery<(Of <(TSource>)>), Func<(Of <(TSource, TKey>)>))
ParallelEnumerable Class See Also Send Feedback

Creates an ILookup{TKey,T} from a ParallelQuery{T} according to a specified key selector function.

Namespace: System.Linq
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function ToLookup(Of TSource, TKey) ( _
    source As ParallelQuery(Of TSource), _
    keySelector As Func(Of TSource, TKey) _
) As ILookup(Of TKey, TSource)
C#
public static ILookup<TKey, TSource> ToLookup<TSource, TKey>(
    ParallelQuery<TSource> source,
    Func<TSource, TKey> keySelector
)

Parameters

source
Type: System.Linq..::.ParallelQuery <(Of <(TSource>)>)
The sequence to create a Lookup<(Of <(TKey, TElement>)>) from.
keySelector
Type: System..::.Func<(Of <(TSource, TKey>)>)
A function to extract a key from each element.

Type Parameters

TSource
The type of elements of source.
TKey
The type of the key returned by keySelector.

Return Value

A Lookup<(Of <(TKey, TElement>)>) that contains keys and values.

Exceptions

Exception | Condition
System..::.ArgumentNullException | source or keySelector is a null reference (Nothing in Visual Basic).
System..::.AggregateException | One or more exceptions occurred during the evaluation of the query.
System..::.OperationCanceledException | The query was canceled.

See Also

ParallelEnumerable Class
ToLookup Overload
System.Linq Namespace


ToLookup(TSource, TKey) Method (ParallelQuery(TSource), Func(TSource, TKey), IEqualityComparer(TKey))

[image]

.NET Framework Class Library
ParallelEnumerable..::.ToLookup<(Of <(TSource, TKey>)>) Method (ParallelQuery<(Of <(TSource>)>), Func<(Of <(TSource, TKey>)>), IEqualityComparer<(Of <(TKey>)>))
ParallelEnumerable Class See Also Send Feedback

Creates an ILookup{TKey,T} from a ParallelQuery{T} according to a specified key selector function and key comparer.

Namespace: System.Linq
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function ToLookup(Of TSource, TKey) ( _
    source As ParallelQuery(Of TSource), _
    keySelector As Func(Of TSource, TKey), _
    comparer As IEqualityComparer(Of TKey) _
) As ILookup(Of TKey, TSource)
C#
public static ILookup<TKey, TSource> ToLookup<TSource, TKey>(
    ParallelQuery<TSource> source,
    Func<TSource, TKey> keySelector,
    IEqualityComparer<TKey> comparer
)

Parameters

source
Type: System.Linq..::.ParallelQuery <(Of <(TSource>)>)
The sequence to create a Lookup<(Of <(TKey, TElement>)>) from.
keySelector
Type: System..::.Func<(Of <(TSource, TKey>)>)
A function to extract a key from each element.
comparer
Type: System.Collections.Generic..::.IEqualityComparer<(Of <(TKey>)>)
An IEqualityComparer<(Of <(T>)>) to compare keys.

Type Parameters

TSource
The type of elements of source.
TKey
The type of the key returned by keySelector.

Return Value

A Lookup<(Of <(TKey, TElement>)>) that contains keys and values.

Exceptions

Exception | Condition
System..::.ArgumentNullException | source or keySelector or is a null reference (Nothing in Visual Basic).
System..::.AggregateException | One or more exceptions occurred during the evaluation of the query.
System..::.OperationCanceledException | The query was canceled.

See Also

ParallelEnumerable Class
ToLookup Overload
System.Linq Namespace


ToLookup(TSource, TKey, TElement) Method (ParallelQuery(TSource), Func(TSource, TKey), Func(TSource, TElement))

[image]

.NET Framework Class Library
ParallelEnumerable..::.ToLookup<(Of <(TSource, TKey, TElement>)>) Method (ParallelQuery<(Of <(TSource>)>), Func<(Of <(TSource, TKey>)>), Func<(Of <(TSource, TElement>)>))
ParallelEnumerable Class See Also Send Feedback

Creates an ILookup{TKey,TElement} from a ParallelQuery{T} according to specified key selector and element selector functions.

Namespace: System.Linq
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function ToLookup(Of TSource, TKey, TElement) ( _
    source As ParallelQuery(Of TSource), _
    keySelector As Func(Of TSource, TKey), _
    elementSelector As Func(Of TSource, TElement) _
) As ILookup(Of TKey, TElement)
C#
public static ILookup<TKey, TElement> ToLookup<TSource, TKey, TElement>(
    ParallelQuery<TSource> source,
    Func<TSource, TKey> keySelector,
    Func<TSource, TElement> elementSelector
)

Parameters

source
Type: System.Linq..::.ParallelQuery <(Of <(TSource>)>)
The sequence to create a Lookup<(Of <(TKey, TElement>)>) from.
keySelector
Type: System..::.Func<(Of <(TSource, TKey>)>)
A function to extract a key from each element.
elementSelector
Type: System..::.Func<(Of <(TSource, TElement>)>)
A transform function to produce a result element value from each element.

Type Parameters

TSource
The type of elements of source.
TKey
The type of the key returned by keySelector.
TElement
The type of the value returned by elementSelector.

Return Value

A Lookup<(Of <(TKey, TElement>)>) that contains values of type TElement selected from the input sequence.

Exceptions

Exception | Condition
System..::.ArgumentNullException | source or keySelector or elementSelector is a null reference (Nothing in Visual Basic).
System..::.AggregateException | One or more exceptions occurred during the evaluation of the query.
System..::.OperationCanceledException | The query was canceled.

See Also

ParallelEnumerable Class
ToLookup Overload
System.Linq Namespace


ToLookup(TSource, TKey, TElement) Method (ParallelQuery(TSource), Func(TSource, TKey), Func(TSource, TElement), IEqualityComparer(TKey))

[image]

.NET Framework Class Library
ParallelEnumerable..::.ToLookup<(Of <(TSource, TKey, TElement>)>) Method (ParallelQuery<(Of <(TSource>)>), Func<(Of <(TSource, TKey>)>), Func<(Of <(TSource, TElement>)>), IEqualityComparer<(Of <(TKey>)>))
ParallelEnumerable Class See Also Send Feedback

Creates an ILookup{TKey,TElement} from a ParallelQuery{T} according to a specified key selector function, a comparer and an element selector function.

Namespace: System.Linq
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function ToLookup(Of TSource, TKey, TElement) ( _
    source As ParallelQuery(Of TSource), _
    keySelector As Func(Of TSource, TKey), _
    elementSelector As Func(Of TSource, TElement), _
    comparer As IEqualityComparer(Of TKey) _
) As ILookup(Of TKey, TElement)
C#
public static ILookup<TKey, TElement> ToLookup<TSource, TKey, TElement>(
    ParallelQuery<TSource> source,
    Func<TSource, TKey> keySelector,
    Func<TSource, TElement> elementSelector,
    IEqualityComparer<TKey> comparer
)

Parameters

source
Type: System.Linq..::.ParallelQuery <(Of <(TSource>)>)
The sequence to create a Lookup<(Of <(TKey, TElement>)>) from.
keySelector
Type: System..::.Func<(Of <(TSource, TKey>)>)
A function to extract a key from each element.
elementSelector
Type: System..::.Func<(Of <(TSource, TElement>)>)
A transform function to produce a result element value from each element.
comparer
Type: System.Collections.Generic..::.IEqualityComparer<(Of <(TKey>)>)
An IEqualityComparer<(Of <(T>)>) to compare keys.

Type Parameters

TSource
The type of elements of source.
TKey
The type of the key returned by keySelector.
TElement
The type of the value returned by elementSelector.

Return Value

A Lookup<(Of <(TKey, TElement>)>) that contains values of type TElement selected from the input sequence.

Exceptions

Exception | Condition
System..::.ArgumentNullException | source or keySelector or elementSelector is a null reference (Nothing in Visual Basic).
System..::.AggregateException | One or more exceptions occurred during the evaluation of the query.
System..::.OperationCanceledException | The query was canceled.

See Also

ParallelEnumerable Class
ToLookup Overload
System.Linq Namespace


Union Method

[image] [image]

.NET Framework Class Library
ParallelEnumerable..::.Union Method
ParallelEnumerable Class See Also Send Feedback

Overload List

Name | Description
Union<(Of <(TSource>)>)(ParallelQuery<(Of <(TSource>)>), IEnumerable<(Of <(TSource>)>)) | Obsolete. This Union overload should never be called. This method is marked as obsolete and always throws NotSupportedException when called.
Union<(Of <(TSource>)>)(ParallelQuery<(Of <(TSource>)>), ParallelQuery<(Of <(TSource>)>)) | Produces the set union of two parallel sequences by using the default equality comparer.
Union<(Of <(TSource>)>)(ParallelQuery<(Of <(TSource>)>), IEnumerable<(Of <(TSource>)>), IEqualityComparer<(Of <(TSource>)>)) | Obsolete. This Union overload should never be called. This method is marked as obsolete and always throws NotSupportedException when called.
Union<(Of <(TSource>)>)(ParallelQuery<(Of <(TSource>)>), ParallelQuery<(Of <(TSource>)>), IEqualityComparer<(Of <(TSource>)>)) | Produces the set union of two parallel sequences by using a specified IEqualityComparer{T}.

See Also

ParallelEnumerable Class
System.Linq Namespace


Union(TSource) Method (ParallelQuery(TSource), IEnumerable(TSource))

[image]

.NET Framework Class Library
ParallelEnumerable..::.Union<(Of <(TSource>)>) Method (ParallelQuery<(Of <(TSource>)>), IEnumerable<(Of <(TSource>)>))
ParallelEnumerable Class See Also Send Feedback

This Union overload should never be called. This method is marked as obsolete and always throws NotSupportedException when called.

Namespace: System.Linq
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
<ObsoleteAttribute("The second data source of a binary operator must be of type System.Linq.ParallelQuery<T> rather than System.Collections.Generic.IEnumerable<T>. To fix this problem, use the AsParallel() extension method to convert the right data source to System.Linq.ParallelQuery<T>.")> _
Public Shared Function Union(Of TSource) ( _
    first As ParallelQuery(Of TSource), _
    second As IEnumerable(Of TSource) _
) As ParallelQuery(Of TSource)
C#
[ObsoleteAttribute("The second data source of a binary operator must be of type System.Linq.ParallelQuery<T> rather than System.Collections.Generic.IEnumerable<T>. To fix this problem, use the AsParallel() extension method to convert the right data source to System.Linq.ParallelQuery<T>.")]
public static ParallelQuery<TSource> Union<TSource>(
    ParallelQuery<TSource> first,
    IEnumerable<TSource> second
)

Parameters

first
Type: System.Linq..::.ParallelQuery <(Of <(TSource>)>)
This parameter is not used.
second
Type: System.Collections.Generic..::.IEnumerable<(Of <(TSource>)>)
This parameter is not used.

Type Parameters

TSource
This type parameter is not used.

Return Value

This overload always throws a NotSupportedException.

Remarks

This overload exists to disallow usage of Union with a left data source of type ParallelQuery<(Of <(TSource>)>) and a right data source of type IEnumerable<(Of <(T>)>). Otherwise, the Union operator would appear to be binding to the parallel implementation, but would in reality bind to sequential implementation.

Exceptions

Exception | Condition
System..::.NotSupportedException | The exception that occurs when this method is called.

See Also

ParallelEnumerable Class
Union Overload
System.Linq Namespace


Union(TSource) Method (ParallelQuery(TSource), ParallelQuery(TSource))

[image]

.NET Framework Class Library
ParallelEnumerable..::.Union<(Of <(TSource>)>) Method (ParallelQuery<(Of <(TSource>)>), ParallelQuery<(Of <(TSource>)>))
ParallelEnumerable Class See Also Send Feedback

Produces the set union of two parallel sequences by using the default equality comparer.

Namespace: System.Linq
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function Union(Of TSource) ( _
    first As ParallelQuery(Of TSource), _
    second As ParallelQuery(Of TSource) _
) As ParallelQuery(Of TSource)
C#
public static ParallelQuery<TSource> Union<TSource>(
    ParallelQuery<TSource> first,
    ParallelQuery<TSource> second
)

Parameters

first
Type: System.Linq..::.ParallelQuery <(Of <(TSource>)>)
A sequence whose distinct elements form the first set for the union.
second
Type: System.Linq..::.ParallelQuery <(Of <(TSource>)>)
A sequence whose distinct elements form the second set for the union.

Type Parameters

TSource
The type of the elements of the input sequences.

Return Value

A sequence that contains the elements from both input sequences, excluding duplicates.

Exceptions

Exception | Condition
System..::.ArgumentNullException | first or second is a null reference (Nothing in Visual Basic).

See Also

ParallelEnumerable Class
Union Overload
System.Linq Namespace


Union(TSource) Method (ParallelQuery(TSource), IEnumerable(TSource), IEqualityComparer(TSource))

[image]

.NET Framework Class Library
ParallelEnumerable..::.Union<(Of <(TSource>)>) Method (ParallelQuery<(Of <(TSource>)>), IEnumerable<(Of <(TSource>)>), IEqualityComparer<(Of <(TSource>)>))
ParallelEnumerable Class See Also Send Feedback

This Union overload should never be called. This method is marked as obsolete and always throws NotSupportedException when called.

Namespace: System.Linq
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
<ObsoleteAttribute("The second data source of a binary operator must be of type System.Linq.ParallelQuery<T> rather than System.Collections.Generic.IEnumerable<T>. To fix this problem, use the AsParallel() extension method to convert the right data source to System.Linq.ParallelQuery<T>.")> _
Public Shared Function Union(Of TSource) ( _
    first As ParallelQuery(Of TSource), _
    second As IEnumerable(Of TSource), _
    comparer As IEqualityComparer(Of TSource) _
) As ParallelQuery(Of TSource)
C#
[ObsoleteAttribute("The second data source of a binary operator must be of type System.Linq.ParallelQuery<T> rather than System.Collections.Generic.IEnumerable<T>. To fix this problem, use the AsParallel() extension method to convert the right data source to System.Linq.ParallelQuery<T>.")]
public static ParallelQuery<TSource> Union<TSource>(
    ParallelQuery<TSource> first,
    IEnumerable<TSource> second,
    IEqualityComparer<TSource> comparer
)

Parameters

first
Type: System.Linq..::.ParallelQuery <(Of <(TSource>)>)
This parameter is not used.
second
Type: System.Collections.Generic..::.IEnumerable<(Of <(TSource>)>)
This parameter is not used.
comparer
Type: System.Collections.Generic..::.IEqualityComparer<(Of <(TSource>)>)
This parameter is not used.

Type Parameters

TSource
This type parameter is not used.

Return Value

This overload always throws a NotSupportedException.

Remarks

This overload exists to disallow usage of Union with a left data source of type ParallelQuery<(Of <(TSource>)>) and a right data source of type IEnumerable<(Of <(T>)>). Otherwise, the Union operator would appear to be binding to the parallel implementation, but would in reality bind to the sequential implementation.

Exceptions

Exception | Condition
System..::.NotSupportedException | The exception that occurs when this method is called.

See Also

ParallelEnumerable Class
Union Overload
System.Linq Namespace


Union(TSource) Method (ParallelQuery(TSource), ParallelQuery(TSource), IEqualityComparer(TSource))

[image]

.NET Framework Class Library
ParallelEnumerable..::.Union<(Of <(TSource>)>) Method (ParallelQuery<(Of <(TSource>)>), ParallelQuery<(Of <(TSource>)>), IEqualityComparer<(Of <(TSource>)>))
ParallelEnumerable Class See Also Send Feedback

Produces the set union of two parallel sequences by using a specified IEqualityComparer{T}.

Namespace: System.Linq
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function Union(Of TSource) ( _
    first As ParallelQuery(Of TSource), _
    second As ParallelQuery(Of TSource), _
    comparer As IEqualityComparer(Of TSource) _
) As ParallelQuery(Of TSource)
C#
public static ParallelQuery<TSource> Union<TSource>(
    ParallelQuery<TSource> first,
    ParallelQuery<TSource> second,
    IEqualityComparer<TSource> comparer
)

Parameters

first
Type: System.Linq..::.ParallelQuery <(Of <(TSource>)>)
A sequence whose distinct elements form the first set for the union.
second
Type: System.Linq..::.ParallelQuery <(Of <(TSource>)>)
A sequence whose distinct elements form the second set for the union.
comparer
Type: System.Collections.Generic..::.IEqualityComparer<(Of <(TSource>)>)
An IEqualityComparer<(Of <(T>)>) to compare values.

Type Parameters

TSource
The type of the elements of the input sequences.

Return Value

A sequence that contains the elements from both input sequences, excluding duplicates.

Exceptions

Exception | Condition
System..::.ArgumentNullException | first or second is a null reference (Nothing in Visual Basic).

See Also

ParallelEnumerable Class
Union Overload
System.Linq Namespace


Where Method

[image] [image]

.NET Framework Class Library
ParallelEnumerable..::.Where Method
ParallelEnumerable Class See Also Send Feedback

Overload List

Name | Description
Where<(Of <(TSource>)>)(ParallelQuery<(Of <(TSource>)>), Func<(Of <(TSource, Boolean>)>)) | Filters in parallel a sequence of values based on a predicate.
Where<(Of <(TSource>)>)(ParallelQuery<(Of <(TSource>)>), Func<(Of <(TSource, Int32, Boolean>)>)) | Filters in parallel a sequence of values based on a predicate. Each element's index is used in the logic of the predicate function.

See Also

ParallelEnumerable Class
System.Linq Namespace


Where(TSource) Method (ParallelQuery(TSource), Func(TSource, Boolean))

[image]

.NET Framework Class Library
ParallelEnumerable..::.Where<(Of <(TSource>)>) Method (ParallelQuery<(Of <(TSource>)>), Func<(Of <(TSource, Boolean>)>))
ParallelEnumerable Class See Also Send Feedback

Filters in parallel a sequence of values based on a predicate.

Namespace: System.Linq
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function Where(Of TSource) ( _
    source As ParallelQuery(Of TSource), _
    predicate As Func(Of TSource, Boolean) _
) As ParallelQuery(Of TSource)
C#
public static ParallelQuery<TSource> Where<TSource>(
    ParallelQuery<TSource> source,
    Func<TSource, bool> predicate
)

Parameters

source
Type: System.Linq..::.ParallelQuery <(Of <(TSource>)>)
A sequence to filter.
predicate
Type: System..::.Func<(Of <(TSource, Boolean>)>)
A function to test each element for a condition.

Type Parameters

TSource
The type of the elements of source.

Return Value

A sequence that contains elements from the input sequence that satisfy the condition.

Exceptions

Exception | Condition
System..::.ArgumentNullException | source or predicate is a null reference (Nothing in Visual Basic).

See Also

ParallelEnumerable Class
Where Overload
System.Linq Namespace


Where(TSource) Method (ParallelQuery(TSource), Func(TSource, Int32, Boolean))

[image]

.NET Framework Class Library
ParallelEnumerable..::.Where<(Of <(TSource>)>) Method (ParallelQuery<(Of <(TSource>)>), Func<(Of <(TSource, Int32, Boolean>)>))
ParallelEnumerable Class See Also Send Feedback

Filters in parallel a sequence of values based on a predicate. Each element's index is used in the logic of the predicate function.

Namespace: System.Linq
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function Where(Of TSource) ( _
    source As ParallelQuery(Of TSource), _
    predicate As Func(Of TSource, Integer, Boolean) _
) As ParallelQuery(Of TSource)
C#
public static ParallelQuery<TSource> Where<TSource>(
    ParallelQuery<TSource> source,
    Func<TSource, int, bool> predicate
)

Parameters

source
Type: System.Linq..::.ParallelQuery <(Of <(TSource>)>)
A sequence to filter.
predicate
Type: System..::.Func<(Of <(TSource, Int32, Boolean>)>)
A function to test each element for a condition.

Type Parameters

TSource
The type of the elements of source.

Return Value

A sequence that contains elements from the input sequence that satisfy the condition.

Exceptions

Exception | Condition
System..::.ArgumentNullException | source or predicate is a null reference (Nothing in Visual Basic).

See Also

ParallelEnumerable Class
Where Overload
System.Linq Namespace


WithCancellation(TSource) Method

[image]

.NET Framework Class Library
ParallelEnumerable..::.WithCancellation<(Of <(TSource>)>) Method
ParallelEnumerable Class See Also Send Feedback

Sets the CancellationToken to associate with the query.

Namespace: System.Linq
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function WithCancellation(Of TSource) ( _
    source As ParallelQuery(Of TSource), _
    cancellationToken As CancellationToken _
) As ParallelQuery(Of TSource)
C#
public static ParallelQuery<TSource> WithCancellation<TSource>(
    ParallelQuery<TSource> source,
    CancellationToken cancellationToken
)

Parameters

source
Type: System.Linq..::.ParallelQuery <(Of <(TSource>)>)
A ParallelQuery on which to set the option.
cancellationToken
Type: System.Threading..::.CancellationToken
A cancellation token.

Type Parameters

TSource
The type of elements of source.

Return Value

ParallelQuery representing the same query as source, but with the registered.

Exceptions

Exception | Condition
System..::.ArgumentNullException | source is a null reference (Nothing in Visual Basic).
System..::.InvalidOperationException | WithCancellation is used multiple times in the query.
System..::.ObjectDisposedException | The CancellationTokenSource associated with the cancellationToken has been disposed.

See Also

ParallelEnumerable Class
System.Linq Namespace
System.Threading..::.CancellationToken


WithDegreeOfParallelism(TSource) Method

[image]

.NET Framework Class Library
ParallelEnumerable..::.WithDegreeOfParallelism<(Of <(TSource>)>) Method
ParallelEnumerable Class See Also Send Feedback

Sets the degree of parallelism to use in a query. Degree of parallelism is the maximum number of concurrently executing tasks that will be used to process the query.

Namespace: System.Linq
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function WithDegreeOfParallelism(Of TSource) ( _
    source As ParallelQuery(Of TSource), _
    degreeOfParallelism As Integer _
) As ParallelQuery(Of TSource)
C#
public static ParallelQuery<TSource> WithDegreeOfParallelism<TSource>(
    ParallelQuery<TSource> source,
    int degreeOfParallelism
)

Parameters

source
Type: System.Linq..::.ParallelQuery <(Of <(TSource>)>)
A ParallelQuery on which to set the limit on the degrees of parallelism.
degreeOfParallelism
Type: System..::.Int32
The degree of parallelism for the query.

Type Parameters

TSource
The type of elements of source.

Return Value

ParallelQuery representing the same query as source, with the limit on the degrees of parallelism set.

Exceptions

Exception | Condition
System..::.ArgumentNullException | source is a null reference (Nothing in Visual Basic).
System..::.InvalidOperationException | WithDegreeOfParallelism is used multiple times in the query.
System..::.ArgumentOutOfRangeException | degreeOfParallelism is less than 1 or greater than 63.

See Also

ParallelEnumerable Class
System.Linq Namespace


WithExecutionMode(TSource) Method

[image]

.NET Framework Class Library
ParallelEnumerable..::.WithExecutionMode<(Of <(TSource>)>) Method
ParallelEnumerable Class See Also Send Feedback

Sets the execution mode of the query.

Namespace: System.Linq
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function WithExecutionMode(Of TSource) ( _
    source As ParallelQuery(Of TSource), _
    executionMode As ParallelExecutionMode _
) As ParallelQuery(Of TSource)
C#
public static ParallelQuery<TSource> WithExecutionMode<TSource>(
    ParallelQuery<TSource> source,
    ParallelExecutionMode executionMode
)

Parameters

source
Type: System.Linq..::.ParallelQuery <(Of <(TSource>)>)
A ParallelQuery on which to set the option.
executionMode
Type: System.Linq..::.ParallelExecutionMode
The mode in which to execute the query.

Type Parameters

TSource
The type of elements of source.

Return Value

ParallelQuery representing the same query as source, but with the registered.

Exceptions

Exception | Condition
System..::.ArgumentNullException | source is a null reference (Nothing in Visual Basic).
System..::.ArgumentException | executionMode is not a valid ParallelExecutionMode value.
System..::.InvalidOperationException | WithExecutionMode is used multiple times in the query.

See Also

ParallelEnumerable Class
System.Linq Namespace
System.Linq..::.ParallelExecutionMode


WithMergeOptions(TSource) Method

[image]

.NET Framework Class Library
ParallelEnumerable..::.WithMergeOptions<(Of <(TSource>)>) Method
ParallelEnumerable Class See Also Send Feedback

Sets the merge options for this query, which specify how the query will buffer output.

Namespace: System.Linq
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function WithMergeOptions(Of TSource) ( _
    source As ParallelQuery(Of TSource), _
    mergeOptions As ParallelMergeOptions _
) As ParallelQuery(Of TSource)
C#
public static ParallelQuery<TSource> WithMergeOptions<TSource>(
    ParallelQuery<TSource> source,
    ParallelMergeOptions mergeOptions
)

Parameters

source
Type: System.Linq..::.ParallelQuery <(Of <(TSource>)>)
A ParallelQuery on which to set the option.
mergeOptions
Type: System.Linq..::.ParallelMergeOptions
The merge optiosn to set for this query.

Type Parameters

TSource
The type of elements of source.

Return Value

ParallelQuery representing the same query as source, but with the registered.

Exceptions

Exception | Condition
System..::.ArgumentNullException | source is a null reference (Nothing in Visual Basic).
System..::.ArgumentException | mergeOptions is not a valid ParallelMergeOptions value.
System..::.InvalidOperationException | WithMergeOptions is used multiple times in the query.

See Also

ParallelEnumerable Class
System.Linq Namespace
System.Linq..::.ParallelMergeOptions


Zip Method

[image] [image]

.NET Framework Class Library
ParallelEnumerable..::.Zip Method
ParallelEnumerable Class See Also Send Feedback

Overload List

Name | Description
Zip<(Of <(TFirst, TSecond, TResult>)>)(ParallelQuery<(Of <(TFirst>)>), IEnumerable<(Of <(TSecond>)>), Func<(Of <(TFirst, TSecond, TResult>)>)) | Obsolete. This Zip overload should never be called. This method is marked as obsolete and always throws NotSupportedException when invoked.
Zip<(Of <(TFirst, TSecond, TResult>)>)(ParallelQuery<(Of <(TFirst>)>), ParallelQuery<(Of <(TSecond>)>), Func<(Of <(TFirst, TSecond, TResult>)>)) | Merges in parallel two sequences by using the specified predicate function.

See Also

ParallelEnumerable Class
System.Linq Namespace


Zip(TFirst, TSecond, TResult) Method (ParallelQuery(TFirst), IEnumerable(TSecond), Func(TFirst, TSecond, TResult))

[image]

.NET Framework Class Library
ParallelEnumerable..::.Zip<(Of <(TFirst, TSecond, TResult>)>) Method (ParallelQuery<(Of <(TFirst>)>), IEnumerable<(Of <(TSecond>)>), Func<(Of <(TFirst, TSecond, TResult>)>))
ParallelEnumerable Class See Also Send Feedback

This Zip overload should never be called. This method is marked as obsolete and always throws NotSupportedException when invoked.

Namespace: System.Linq
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
<ObsoleteAttribute("The second data source of a binary operator must be of type System.Linq.ParallelQuery<T> rather than System.Collections.Generic.IEnumerable<T>. To fix this problem, use the AsParallel() extension method to convert the right data source to System.Linq.ParallelQuery<T>.")> _
Public Shared Function Zip(Of TFirst, TSecond, TResult) ( _
    first As ParallelQuery(Of TFirst), _
    second As IEnumerable(Of TSecond), _
    resultSelector As Func(Of TFirst, TSecond, TResult) _
) As ParallelQuery(Of TResult)
C#
[ObsoleteAttribute("The second data source of a binary operator must be of type System.Linq.ParallelQuery<T> rather than System.Collections.Generic.IEnumerable<T>. To fix this problem, use the AsParallel() extension method to convert the right data source to System.Linq.ParallelQuery<T>.")]
public static ParallelQuery<TResult> Zip<TFirst, TSecond, TResult>(
    ParallelQuery<TFirst> first,
    IEnumerable<TSecond> second,
    Func<TFirst, TSecond, TResult> resultSelector
)

Parameters

first
Type: System.Linq..::.ParallelQuery <(Of <(TFirst>)>)
This parameter is not used.
second
Type: System.Collections.Generic..::.IEnumerable<(Of <(TSecond>)>)
This parameter is not used.
resultSelector
Type: System..::.Func<(Of <(TFirst, TSecond, TResult>)>)
This parameter is not used.

Type Parameters

TFirst
This type parameter is not used.
TSecond
This type parameter is not used.
TResult
This type parameter is not used.

Return Value

This overload always throws a NotSupportedException.

Remarks

This overload exists to disallow usage of Zip with a left data source of type ParallelQuery<(Of <(TSource>)>) and a right data source of type IEnumerable<(Of <(T>)>). Otherwise, the Zip operator would appear to be bind to the parallel implementation, but would in reality bind to the sequential implementation.

Exceptions

Exception | Condition
System..::.NotSupportedException | The exception that occurs when this method is called.

See Also

ParallelEnumerable Class
Zip Overload
System.Linq Namespace


Zip(TFirst, TSecond, TResult) Method (ParallelQuery(TFirst), ParallelQuery(TSecond), Func(TFirst, TSecond, TResult))

[image]

.NET Framework Class Library
ParallelEnumerable..::.Zip<(Of <(TFirst, TSecond, TResult>)>) Method (ParallelQuery<(Of <(TFirst>)>), ParallelQuery<(Of <(TSecond>)>), Func<(Of <(TFirst, TSecond, TResult>)>))
ParallelEnumerable Class See Also Send Feedback

Merges in parallel two sequences by using the specified predicate function.

Namespace: System.Linq
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function Zip(Of TFirst, TSecond, TResult) ( _
    first As ParallelQuery(Of TFirst), _
    second As ParallelQuery(Of TSecond), _
    resultSelector As Func(Of TFirst, TSecond, TResult) _
) As ParallelQuery(Of TResult)
C#
public static ParallelQuery<TResult> Zip<TFirst, TSecond, TResult>(
    ParallelQuery<TFirst> first,
    ParallelQuery<TSecond> second,
    Func<TFirst, TSecond, TResult> resultSelector
)

Parameters

first
Type: System.Linq..::.ParallelQuery <(Of <(TFirst>)>)
The first sequence to zip.
second
Type: System.Linq..::.ParallelQuery <(Of <(TSecond>)>)
The second sequence to zip.
resultSelector
Type: System..::.Func<(Of <(TFirst, TSecond, TResult>)>)
A function to create a result element from two matching elements.

Type Parameters

TFirst
The type of the elements of the first sequence.
TSecond
The type of the elements of the second sequence.
TResult
The type of the return elements.

Return Value

A sequence that has elements of type TResult that are obtained by performing resultSelector pairwise on two sequences. If the sequence lengths are unequal, this truncates to the length of the shorter sequence.

Exceptions

Exception | Condition
System..::.ArgumentNullException | first or second or resultSelector is a null reference (Nothing in Visual Basic).

See Also

ParallelEnumerable Class
Zip Overload
System.Linq Namespace


ParallelExecutionMode Enumeration

[image]

.NET Framework Class Library
ParallelExecutionMode Enumeration
See Also Send Feedback

The query execution mode is a hint that specifies how the system should handle performance trade-offs when parallelizing queries.

Namespace: System.Linq
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Enumeration ParallelExecutionMode
C#
public enum ParallelExecutionMode

Members

Member name | Description
Default | By default, the system will use algorithms for queries that are ripe for parallelism and will avoid algorithms with high overheads that will likely result in slow downs for parallel execution.
ForceParallelism | Parallelize the entire query, even if that means using high-overhead algorithms.

See Also

System.Linq Namespace


ParallelMergeOptions Enumeration

[image]

.NET Framework Class Library
ParallelMergeOptions Enumeration
See Also Send Feedback

Specifies the preferred type of output merge to use in a query. This is a hint only, and may not be respected by the system when parallelizing all queries.

Namespace: System.Linq
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Enumeration ParallelMergeOptions
C#
public enum ParallelMergeOptions

Members

Member name | Description
Default | Use the default merge type, which is AutoBuffered.
NotBuffered | Use a merge without output buffers. As soon as result elements have been computed, make that element available to the consumer of the query.
AutoBuffered | Use a merge with output buffers of a size chosen by the system. Results will accumulate into an output buffer before they are available to the consumer of the query.
FullyBuffered | Use a merge with full output buffers. The system will accumulate all of the results before making any of them available to the consumer of the query.

Remarks

Use NotBuffered for queries that will be consumed and output as streams, this has the lowest latency between beginning query execution and elements being yielded. For some queries, such as those involving a sort (OrderBy, OrderByDescending), buffering is essential and a hint of NotBuffered or AutoBuffered will be ignored.

Use AutoBuffered for most cases; this is the default. It strikes a balance between latency and overall performance.

Use FullyBuffered for queries when the entire output can be processed before the information is needed. This option offers the best performance when all of the output can be accumulated before yielding any information, though it is not suitable for stream processing or showing partial results mid-query.

See Also

System.Linq Namespace


ParallelQuery Class

[image]

.NET Framework Class Library
ParallelQuery Class
See Also Send Feedback

Represents a parallel sequence.

Namespace: System.Linq
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Class ParallelQuery _
    Implements IEnumerable
C#
public class ParallelQuery : IEnumerable

Inheritance Hierarchy

System..::.Object
System.Linq..::.ParallelQuery
System.Linq..::.ParallelQuery<(Of <(TSource>)>)

See Also

System.Linq Namespace


ParallelQuery Methods

[image] [image]

.NET Framework Class Library
ParallelQuery Methods
ParallelQuery Class See Also Send Feedback

The ParallelQuery type exposes the following members.

Methods

Name | Description
Equals | (Inherited from Object.)
Finalize | (Inherited from Object.)
GetHashCode | (Inherited from Object.)
GetType | (Inherited from Object.)
MemberwiseClone | (Inherited from Object.)
ToString | (Inherited from Object.)

Explicit Interface Implementations

Name | Description
IEnumerable..::.GetEnumerator | Returns an enumerator that iterates through the sequence.

See Also

ParallelQuery Class
System.Linq Namespace


IEnumerable.GetEnumerator Method

[image]

.NET Framework Class Library
ParallelQuery..::.IEnumerable..::.GetEnumerator Method
ParallelQuery Class See Also Send Feedback

Returns an enumerator that iterates through the sequence.

Namespace: System.Linq
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Private Function GetEnumerator As IEnumerator
    Implements IEnumerable.GetEnumerator
C#
IEnumerator IEnumerable.GetEnumerator()

Return Value

An enumerator that iterates through the sequence.

Implements

IEnumerable..::.GetEnumerator()()()

See Also

ParallelQuery Class
System.Linq Namespace


ParallelQuery(TSource) Class

[image]

.NET Framework Class Library
ParallelQuery<(Of <(TSource>)>) Class
See Also Send Feedback

Represents a parallel sequence.

Namespace: System.Linq
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Class ParallelQuery(Of TSource) _
    Inherits ParallelQuery _
    Implements IEnumerable(Of T), IEnumerable
C#
public class ParallelQuery<TSource> : ParallelQuery,
    IEnumerable<T>, IEnumerable

Type Parameters

TSource

Inheritance Hierarchy

System..::.Object
System.Linq..::.ParallelQuery
System.Linq..::.ParallelQuery<(Of <(TSource>)>)
System.Linq..::.OrderedParallelQuery<(Of <(TSource>)>)

See Also

System.Linq Namespace


ParallelQuery(TSource) Methods

[image] [image]

.NET Framework Class Library
ParallelQuery<(Of <(TSource>)>) Methods
ParallelQuery<(Of <(TSource>)>) Class See Also Send Feedback

The ParallelQuery<(Of <(TSource>)>) type exposes the following members.

Methods

Name | Description
Equals | (Inherited from Object.)
Finalize | (Inherited from Object.)
GetEnumerator | Returns an enumerator that iterates through the sequence.
GetHashCode | (Inherited from Object.)
GetType | (Inherited from Object.)
MemberwiseClone | (Inherited from Object.)
ToString | (Inherited from Object.)

Explicit Interface Implementations

Name | Description
IEnumerable..::.GetEnumerator | Returns an enumerator that iterates through the sequence. (Inherited from ParallelQuery.)

See Also

ParallelQuery<(Of <(TSource>)>) Class
System.Linq Namespace


GetEnumerator Method

[image]

.NET Framework Class Library
ParallelQuery<(Of <(TSource>)>)..::.GetEnumerator Method
ParallelQuery<(Of <(TSource>)>) Class See Also Send Feedback

Returns an enumerator that iterates through the sequence.

Namespace: System.Linq
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Overridable Function GetEnumerator As IEnumerator(Of TSource)
C#
public virtual IEnumerator<TSource> GetEnumerator()

Return Value

An enumerator that iterates through the sequence.

See Also

ParallelQuery<(Of <(TSource>)>) Class
System.Linq Namespace


System.Threading Namespace

[image]

.NET Framework Class Library
System.Threading Namespace
Send Feedback

Classes

Class | Description
Barrier | Enables multiple tasks to cooperatively work on an algorithm in parallel through multiple phases.
BarrierPostPhaseException | The exception that is thrown when the post-phase action of a Barrier fails.
CancellationTokenSource | Signals to a CancellationToken that it should be canceled.
CountdownEvent | Represents a synchronization primitive that is signaled when its count reaches zero.
LazyInitializer | Provides lazy initialization routines.
ManualResetEventSlim | Provides a slimmed down version of ManualResetEvent.
SemaphoreSlim | Limits the number of threads that can access a resource or pool of resources concurrently.
ThreadLocal<(Of <(T>)>) | Provides thread-local storage of data.

Structures

Structure | Description
CancellationToken | Propogates notification that operations should be canceled.
CancellationTokenRegistration | Represents a callback delegate that has been registered with a CancellationToken.
SpinLock | Provides a mutual exclusion lock primitive where a thread trying to acquire the lock waits in a loop repeatedly checking until the lock becomes available.
SpinWait | Provides support for spin-based waiting.

Enumerations

Enumeration | Description
LazyThreadSafetyMode | Specifies how a Lazy<(Of <(T>)>) instance should synchronize access among multiple threads.


Barrier Class

[image]

.NET Framework Class Library
Barrier Class
See Also Send Feedback

Enables multiple tasks to cooperatively work on an algorithm in parallel through multiple phases.

Namespace: System.Threading
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
<ComVisibleAttribute(False)> _
<HostProtectionAttribute(SecurityAction.LinkDemand, Synchronization := True,  _
    ExternalThreading := True)> _
Public Class Barrier _
    Implements IDisposable
C#
[ComVisibleAttribute(false)]
[HostProtectionAttribute(SecurityAction.LinkDemand, Synchronization = true,
    ExternalThreading = true)]
public class Barrier : IDisposable

Remarks

A group of tasks cooperate by moving through a series of phases, where each in the group signals it has arrived at the Barrier in a given phase and implicitly waits for all others to arrive. The same Barrier can be used for multiple phases.

All public and protected members of Barrier are thread-safe and may be used concurrently from multiple threads, with the exception of Dispose, which must only be used when all other operations on the Barrier have completed.

Inheritance Hierarchy

System..::.Object
System.Threading..::.Barrier

See Also

System.Threading Namespace


Barrier Constructor

[image] [image]

.NET Framework Class Library
Barrier Constructor
Barrier Class See Also Send Feedback

Overload List

Name | Description
Barrier(Int32) | Initializes a new instance of the Barrier class.
Barrier(Int32, Action<(Of <(Barrier>)>)) | Initializes a new instance of the Barrier class.

See Also

Barrier Class
System.Threading Namespace


Barrier Constructor (Int32)

[image]

.NET Framework Class Library
Barrier Constructor (Int32)
Barrier Class See Also Send Feedback

Initializes a new instance of the Barrier class.

Namespace: System.Threading
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Sub New ( _
    participantCount As Integer _
)
C#
public Barrier(
    int participantCount
)

Parameters

participantCount
Type: System..::.Int32
The number of participating threads.

Exceptions

Exception | Condition
System..::.ArgumentOutOfRangeException | participantCount is less than 0 or greater than MaxValue.

See Also

Barrier Class
Barrier Overload
System.Threading Namespace


Barrier Constructor (Int32, Action(Barrier))

[image]

.NET Framework Class Library
Barrier Constructor (Int32, Action<(Of <(Barrier>)>))
Barrier Class See Also Send Feedback

Initializes a new instance of the Barrier class.

Namespace: System.Threading
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Sub New ( _
    participantCount As Integer, _
    postPhaseAction As Action(Of Barrier) _
)
C#
public Barrier(
    int participantCount,
    Action<Barrier> postPhaseAction
)

Parameters

participantCount
Type: System..::.Int32
The number of participating threads.
postPhaseAction
Type: System..::.Action<(Of <( Barrier >)>)
The Action<(Of <(T>)>) to be executed after each phase.

Remarks

The postPhaseAction delegate will be executed after all participants have arrived at the barrier in one phase. The participants will not be released to the next phase until the postPhaseAction delegate has completed execution.

Exceptions

Exception | Condition
System..::.ArgumentOutOfRangeException | participantCount is less than 0 or greater than MaxValue.

See Also

Barrier Class
Barrier Overload
System.Threading Namespace


Barrier Methods

[image] [image]

.NET Framework Class Library
Barrier Methods
Barrier Class See Also Send Feedback

The Barrier type exposes the following members.

Methods

Name | Description
AddParticipant | Notifies the Barrier that there will be an additional participant.
AddParticipants | Notifies the Barrier that there will be additional participants.
Dispose | Overloaded.
Equals | (Inherited from Object.)
Finalize | (Inherited from Object.)
GetHashCode | (Inherited from Object.)
GetType | (Inherited from Object.)
MemberwiseClone | (Inherited from Object.)
RemoveParticipant | Notifies the Barrier that there will be one less participant.
RemoveParticipants | Notifies the Barrier that there will be fewer participants.
SignalAndWait | Overloaded.
ToString | (Inherited from Object.)

See Also

Barrier Class
System.Threading Namespace


AddParticipant Method

[image]

.NET Framework Class Library
Barrier..::.AddParticipant Method
Barrier Class See Also Send Feedback

Notifies the Barrier that there will be an additional participant.

Namespace: System.Threading
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Function AddParticipant As Long
C#
public long AddParticipant()

Return Value

The phase number of the barrier in which the new participants will first participate.

Exceptions

Exception | Condition
System..::.InvalidOperationException | Adding a participant would cause the barrier's participant count to exceed MaxValue.
System..::.InvalidOperationException | The method was invoked from within a post-phase action.
System..::.ObjectDisposedException | The current instance has already been disposed.

See Also

Barrier Class
System.Threading Namespace


AddParticipants Method

[image]

.NET Framework Class Library
Barrier..::.AddParticipants Method
Barrier Class See Also Send Feedback

Notifies the Barrier that there will be additional participants.

Namespace: System.Threading
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Function AddParticipants ( _
    participantCount As Integer _
) As Long
C#
public long AddParticipants(
    int participantCount
)

Parameters

participantCount
Type: System..::.Int32
The number of additional participants to add to the barrier.

Return Value

The phase number of the barrier in which the new participants will first participate.

Exceptions

Exception | Condition
System..::.ArgumentOutOfRangeException | participantCount is less than 0.
System..::.ArgumentOutOfRangeException | Adding participantCount participants would cause the barrier's participant count to exceed MaxValue.
System..::.InvalidOperationException | The method was invoked from within a post-phase action.
System..::.ObjectDisposedException | The current instance has already been disposed.

See Also

Barrier Class
System.Threading Namespace


Dispose Method

[image] [image]

.NET Framework Class Library
Barrier..::.Dispose Method
Barrier Class See Also Send Feedback

Overload List

Name | Description
Dispose()()() | Releases all resources used by the current instance of Barrier.
Dispose(Boolean) | When overridden in a derived class, releases the unmanaged resources used by the Barrier, and optionally releases the managed resources.

See Also

Barrier Class
System.Threading Namespace


Dispose Method

[image]

.NET Framework Class Library
Barrier..::.Dispose Method
Barrier Class See Also Send Feedback

Releases all resources used by the current instance of Barrier.

Namespace: System.Threading
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Sub Dispose
C#
public void Dispose()

Implements

IDisposable..::.Dispose()()()

Remarks

Unlike most of the members of Barrier, Dispose is not thread-safe and may not be used concurrently with other members of this instance.

Exceptions

Exception | Condition
System..::.InvalidOperationException | The method was invoked from within a post-phase action.

See Also

Barrier Class
Dispose Overload
System.Threading Namespace


Dispose Method (Boolean)

[image]

.NET Framework Class Library
Barrier..::.Dispose Method (Boolean)
Barrier Class See Also Send Feedback

When overridden in a derived class, releases the unmanaged resources used by the Barrier, and optionally releases the managed resources.

Namespace: System.Threading
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Protected Overridable Sub Dispose ( _
    disposing As Boolean _
)
C#
protected virtual void Dispose(
    bool disposing
)

Parameters

disposing
Type: System..::.Boolean
true to release both managed and unmanaged resources; false to release only unmanaged resources.

Remarks

Unlike most of the members of Barrier, Dispose is not thread-safe and may not be used concurrently with other members of this instance.

See Also

Barrier Class
Dispose Overload
System.Threading Namespace


RemoveParticipant Method

[image]

.NET Framework Class Library
Barrier..::.RemoveParticipant Method
Barrier Class See Also Send Feedback

Notifies the Barrier that there will be one less participant.

Namespace: System.Threading
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Sub RemoveParticipant
C#
public void RemoveParticipant()

Exceptions

Exception | Condition
System..::.InvalidOperationException | The barrier already has 0 participants.
System..::.InvalidOperationException | The method was invoked from within a post-phase action.
System..::.ObjectDisposedException | The current instance has already been disposed.

See Also

Barrier Class
System.Threading Namespace


RemoveParticipants Method

[image]

.NET Framework Class Library
Barrier..::.RemoveParticipants Method
Barrier Class See Also Send Feedback

Notifies the Barrier that there will be fewer participants.

Namespace: System.Threading
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Sub RemoveParticipants ( _
    participantCount As Integer _
)
C#
public void RemoveParticipants(
    int participantCount
)

Parameters

participantCount
Type: System..::.Int32
The number of additional participants to remove from the barrier.

Exceptions

Exception | Condition
System..::.ArgumentOutOfRangeException | participantCount is less than 0.
System..::.InvalidOperationException | The barrier already has 0 participants.
System..::.InvalidOperationException | The method was invoked from within a post-phase action.
System..::.ObjectDisposedException | The current instance has already been disposed.

See Also

Barrier Class
System.Threading Namespace


SignalAndWait Method

[image] [image]

.NET Framework Class Library
Barrier..::.SignalAndWait Method
Barrier Class See Also Send Feedback

Overload List

Name | Description
SignalAndWait()()() | Signals that a participant has reached the Barrier and waits for all other participants to reach the barrier as well.
SignalAndWait(Int32) | Signals that a participant has reached the Barrier and waits for all other participants to reach the barrier as well, using a 32-bit signed integer to measure the time interval.
SignalAndWait(CancellationToken) | Signals that a participant has reached the Barrier and waits for all other participants to reach the barrier, while observing a CancellationToken.
SignalAndWait(TimeSpan) | Signals that a participant has reached the Barrier and waits for all other participants to reach the barrier as well, using a TimeSpan to measure the time interval.
SignalAndWait(Int32, CancellationToken) | Signals that a participant has reached the barrier and waits for all other participants to reach the barrier as well, using a 32-bit signed integer to measure the time interval, while observing a CancellationToken.
SignalAndWait(TimeSpan, CancellationToken) | Signals that a participant has reached the Barrier and waits for all other participants to reach the barrier as well, using a TimeSpan to measure the time interval, while observing a CancellationToken.

See Also

Barrier Class
System.Threading Namespace


SignalAndWait Method

[image]

.NET Framework Class Library
Barrier..::.SignalAndWait Method
Barrier Class See Also Send Feedback

Signals that a participant has reached the Barrier and waits for all other participants to reach the barrier as well.

Namespace: System.Threading
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Sub SignalAndWait
C#
public void SignalAndWait()

Exceptions

Exception | Condition
System..::.InvalidOperationException | The method was invoked from within a post-phase action, the barrier currently has 0 participants, or the barrier is being used by more threads than are registered as participants.
System..::.ObjectDisposedException | The current instance has already been disposed.

See Also

Barrier Class
SignalAndWait Overload
System.Threading Namespace


SignalAndWait Method (Int32)

[image]

.NET Framework Class Library
Barrier..::.SignalAndWait Method (Int32)
Barrier Class See Also Send Feedback

Signals that a participant has reached the Barrier and waits for all other participants to reach the barrier as well, using a 32-bit signed integer to measure the time interval.

Namespace: System.Threading
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Function SignalAndWait ( _
    millisecondsTimeout As Integer _
) As Boolean
C#
public bool SignalAndWait(
    int millisecondsTimeout
)

Parameters

millisecondsTimeout
Type: System..::.Int32
The number of milliseconds to wait, or Infinite(-1) to wait indefinitely.

Return Value

true if all other participants reached the barrier; otherwise, false.

Exceptions

Exception | Condition
System..::.ArgumentOutOfRangeException | millisecondsTimeout is a negative number other than -1, which represents an infinite time-out.
System..::.InvalidOperationException | The method was invoked from within a post-phase action, the barrier currently has 0 participants, or the barrier is being used by more threads than are registered as participants.
System..::.ObjectDisposedException | The current instance has already been disposed.

See Also

Barrier Class
SignalAndWait Overload
System.Threading Namespace


SignalAndWait Method (CancellationToken)

[image]

.NET Framework Class Library
Barrier..::.SignalAndWait Method (CancellationToken)
Barrier Class See Also Send Feedback

Signals that a participant has reached the Barrier and waits for all other participants to reach the barrier, while observing a CancellationToken.

Namespace: System.Threading
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Sub SignalAndWait ( _
    cancellationToken As CancellationToken _
)
C#
public void SignalAndWait(
    CancellationToken cancellationToken
)

Parameters

cancellationToken
Type: System.Threading..::.CancellationToken
The CancellationToken to observe.

Exceptions

Exception | Condition
System..::.InvalidOperationException | The method was invoked from within a post-phase action, the barrier currently has 0 participants, or the barrier is being used by more threads than are registered as participants.
System..::.OperationCanceledException | cancellationToken has been canceled.
System..::.ObjectDisposedException | The current instance has already been disposed.

See Also

Barrier Class
SignalAndWait Overload
System.Threading Namespace


SignalAndWait Method (TimeSpan)

[image]

.NET Framework Class Library
Barrier..::.SignalAndWait Method (TimeSpan)
Barrier Class See Also Send Feedback

Signals that a participant has reached the Barrier and waits for all other participants to reach the barrier as well, using a TimeSpan to measure the time interval.

Namespace: System.Threading
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Function SignalAndWait ( _
    timeout As TimeSpan _
) As Boolean
C#
public bool SignalAndWait(
    TimeSpan timeout
)

Parameters

timeout
Type: System..::.TimeSpan
A TimeSpan that represents the number of milliseconds to wait, or a TimeSpan that represents -1 milliseconds to wait indefinitely.

Return Value

true if all other participants reached the barrier; otherwise, false.

Exceptions

Exception | Condition
System..::.ArgumentOutOfRangeException | timeoutis a negative number other than -1 milliseconds, which represents an infinite time-out, or it is greater than MaxValue.
System..::.InvalidOperationException | The method was invoked from within a post-phase action, the barrier currently has 0 participants, or the barrier is being used by more threads than are registered as participants.
System..::.ObjectDisposedException | The current instance has already been disposed.

See Also

Barrier Class
SignalAndWait Overload
System.Threading Namespace


SignalAndWait Method (Int32, CancellationToken)

[image]

.NET Framework Class Library
Barrier..::.SignalAndWait Method (Int32, CancellationToken)
Barrier Class See Also Send Feedback

Signals that a participant has reached the barrier and waits for all other participants to reach the barrier as well, using a 32-bit signed integer to measure the time interval, while observing a CancellationToken.

Namespace: System.Threading
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Function SignalAndWait ( _
    millisecondsTimeout As Integer, _
    cancellationToken As CancellationToken _
) As Boolean
C#
public bool SignalAndWait(
    int millisecondsTimeout,
    CancellationToken cancellationToken
)

Parameters

millisecondsTimeout
Type: System..::.Int32
The number of milliseconds to wait, or Infinite(-1) to wait indefinitely.
cancellationToken
Type: System.Threading..::.CancellationToken
The CancellationToken to observe.

Return Value

true if all other participants reached the barrier; otherwise, false.

Exceptions

Exception | Condition
System..::.ArgumentOutOfRangeException | millisecondsTimeout is a negative number other than -1, which represents an infinite time-out.
System..::.InvalidOperationException | The method was invoked from within a post-phase action, the barrier currently has 0 participants, or the barrier is being used by more threads than are registered as participants.
System..::.OperationCanceledException | cancellationToken has been canceled.
System..::.ObjectDisposedException | The current instance has already been disposed.

See Also

Barrier Class
SignalAndWait Overload
System.Threading Namespace


SignalAndWait Method (TimeSpan, CancellationToken)

[image]

.NET Framework Class Library
Barrier..::.SignalAndWait Method (TimeSpan, CancellationToken)
Barrier Class See Also Send Feedback

Signals that a participant has reached the Barrier and waits for all other participants to reach the barrier as well, using a TimeSpan to measure the time interval, while observing a CancellationToken.

Namespace: System.Threading
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Function SignalAndWait ( _
    timeout As TimeSpan, _
    cancellationToken As CancellationToken _
) As Boolean
C#
public bool SignalAndWait(
    TimeSpan timeout,
    CancellationToken cancellationToken
)

Parameters

timeout
Type: System..::.TimeSpan
A TimeSpan that represents the number of milliseconds to wait, or a TimeSpan that represents -1 milliseconds to wait indefinitely.
cancellationToken
Type: System.Threading..::.CancellationToken
The CancellationToken to observe.

Return Value

true if all other participants reached the barrier; otherwise, false.

Exceptions

Exception | Condition
System..::.ArgumentOutOfRangeException | timeoutis a negative number other than -1 milliseconds, which represents an infinite time-out.
System..::.InvalidOperationException | The method was invoked from within a post-phase action, the barrier currently has 0 participants, or the barrier is being used by more threads than are registered as participants.
System..::.OperationCanceledException | cancellationToken has been canceled.
System..::.ObjectDisposedException | The current instance has already been disposed.

See Also

Barrier Class
SignalAndWait Overload
System.Threading Namespace


Barrier Properties

[image] [image]

.NET Framework Class Library
Barrier Properties
Barrier Class See Also Send Feedback

The Barrier type exposes the following members.

Properties

Name | Description
CurrentPhaseNumber | Gets the number of the barrier's current phase.
ParticipantCount | Gets the total number of participants in the barrier.
ParticipantsRemaining | Gets the number of participants in the barrier that haven’t yet signaled in the current phase.

See Also

Barrier Class
System.Threading Namespace


CurrentPhaseNumber Property

[image]

.NET Framework Class Library
Barrier..::.CurrentPhaseNumber Property
Barrier Class See Also Send Feedback

Gets the number of the barrier's current phase.

Namespace: System.Threading
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public ReadOnly Property CurrentPhaseNumber As Long
C#
public long CurrentPhaseNumber { get; }

See Also

Barrier Class
System.Threading Namespace


ParticipantCount Property

[image]

.NET Framework Class Library
Barrier..::.ParticipantCount Property
Barrier Class See Also Send Feedback

Gets the total number of participants in the barrier.

Namespace: System.Threading
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public ReadOnly Property ParticipantCount As Integer
C#
public int ParticipantCount { get; }

See Also

Barrier Class
System.Threading Namespace


ParticipantsRemaining Property

[image]

.NET Framework Class Library
Barrier..::.ParticipantsRemaining Property
Barrier Class See Also Send Feedback

Gets the number of participants in the barrier that haven’t yet signaled in the current phase.

Namespace: System.Threading
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public ReadOnly Property ParticipantsRemaining As Integer
C#
public int ParticipantsRemaining { get; }

Remarks

This could be 0 during a post-phase action delegate execution or if the ParticipantCount is 0.

See Also

Barrier Class
System.Threading Namespace


BarrierPostPhaseException Class

[image]

.NET Framework Class Library
BarrierPostPhaseException Class
See Also Send Feedback

The exception that is thrown when the post-phase action of a Barrier fails.

Namespace: System.Threading
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
<SerializableAttribute> _
Public Class BarrierPostPhaseException _
    Inherits Exception
C#
[SerializableAttribute]
public class BarrierPostPhaseException : Exception

Inheritance Hierarchy

System..::.Object
System..::.Exception
System.Threading..::.BarrierPostPhaseException

See Also

System.Threading Namespace


BarrierPostPhaseException Constructor

[image] [image]

.NET Framework Class Library
BarrierPostPhaseException Constructor
BarrierPostPhaseException Class See Also Send Feedback

Overload List

Name | Description
BarrierPostPhaseException()()() | Initializes a new instance of the BarrierPostPhaseException class.
BarrierPostPhaseException(Exception) | Initializes a new instance of the BarrierPostPhaseException class with the specified inner exception.
BarrierPostPhaseException(String) | Initializes a new instance of the BarrierPostPhaseException class with a specified error message.
BarrierPostPhaseException(SerializationInfo, StreamingContext) | Initializes a new instance of the BarrierPostPhaseException class with serialized data.
BarrierPostPhaseException(String, Exception) | Initializes a new instance of the BarrierPostPhaseException class with a specified error message and inner exception.

See Also

BarrierPostPhaseException Class
System.Threading Namespace


BarrierPostPhaseException Constructor

[image]

.NET Framework Class Library
BarrierPostPhaseException Constructor
BarrierPostPhaseException Class See Also Send Feedback

Initializes a new instance of the BarrierPostPhaseException class.

Namespace: System.Threading
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Sub New
C#
public BarrierPostPhaseException()

See Also

BarrierPostPhaseException Class
BarrierPostPhaseException Overload
System.Threading Namespace


BarrierPostPhaseException Constructor (Exception)

[image]

.NET Framework Class Library
BarrierPostPhaseException Constructor (Exception)
BarrierPostPhaseException Class See Also Send Feedback

Initializes a new instance of the BarrierPostPhaseException class with the specified inner exception.

Namespace: System.Threading
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Sub New ( _
    innerException As Exception _
)
C#
public BarrierPostPhaseException(
    Exception innerException
)

Parameters

innerException
Type: System..::.Exception
The exception that is the cause of the current exception.

See Also

BarrierPostPhaseException Class
BarrierPostPhaseException Overload
System.Threading Namespace


BarrierPostPhaseException Constructor (String)

[image]

.NET Framework Class Library
BarrierPostPhaseException Constructor (String)
BarrierPostPhaseException Class See Also Send Feedback

Initializes a new instance of the BarrierPostPhaseException class with a specified error message.

Namespace: System.Threading
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Sub New ( _
    message As String _
)
C#
public BarrierPostPhaseException(
    string message
)

Parameters

message
Type: System..::.String
A string that describes the exception.

See Also

BarrierPostPhaseException Class
BarrierPostPhaseException Overload
System.Threading Namespace


BarrierPostPhaseException Constructor (SerializationInfo, StreamingContext)

[image]

.NET Framework Class Library
BarrierPostPhaseException Constructor (SerializationInfo, StreamingContext)
BarrierPostPhaseException Class See Also Send Feedback

Initializes a new instance of the BarrierPostPhaseException class with serialized data.

Namespace: System.Threading
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Protected Sub New ( _
    info As SerializationInfo, _
    context As StreamingContext _
)
C#
protected BarrierPostPhaseException(
    SerializationInfo info,
    StreamingContext context
)

Parameters

info
Type: System.Runtime.Serialization..::.SerializationInfo
The object that holds the serialized object data.
context
Type: System.Runtime.Serialization..::.StreamingContext
An object that describes the source or destination of the serialized data.

See Also

BarrierPostPhaseException Class
BarrierPostPhaseException Overload
System.Threading Namespace


BarrierPostPhaseException Constructor (String, Exception)

[image]

.NET Framework Class Library
BarrierPostPhaseException Constructor (String, Exception)
BarrierPostPhaseException Class See Also Send Feedback

Initializes a new instance of the BarrierPostPhaseException class with a specified error message and inner exception.

Namespace: System.Threading
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Sub New ( _
    message As String, _
    innerException As Exception _
)
C#
public BarrierPostPhaseException(
    string message,
    Exception innerException
)

Parameters

message
Type: System..::.String
A string that describes the exception.
innerException
Type: System..::.Exception
The exception that is the cause of the current exception.

See Also

BarrierPostPhaseException Class
BarrierPostPhaseException Overload
System.Threading Namespace


BarrierPostPhaseException Methods

[image] [image]

.NET Framework Class Library
BarrierPostPhaseException Methods
BarrierPostPhaseException Class See Also Send Feedback

The BarrierPostPhaseException type exposes the following members.

Methods

Name | Description
Equals | (Inherited from Object.)
Finalize | (Inherited from Object.)
GetBaseException | (Inherited from Exception.)
GetHashCode | (Inherited from Object.)
GetObjectData | (Inherited from Exception.)
GetType | (Inherited from Exception.)
MemberwiseClone | (Inherited from Object.)
ToString | (Inherited from Exception.)

See Also

BarrierPostPhaseException Class
System.Threading Namespace


BarrierPostPhaseException Properties

[image] [image]

.NET Framework Class Library
BarrierPostPhaseException Properties
BarrierPostPhaseException Class See Also Send Feedback

The BarrierPostPhaseException type exposes the following members.

Properties

Name | Description
Data | (Inherited from Exception.)
HelpLink | (Inherited from Exception.)
HResult | (Inherited from Exception.)
InnerException | (Inherited from Exception.)
Message | (Inherited from Exception.)
Source | (Inherited from Exception.)
StackTrace | (Inherited from Exception.)
TargetSite | (Inherited from Exception.)

See Also

BarrierPostPhaseException Class
System.Threading Namespace


CancellationToken Structure

[image]

.NET Framework Class Library
CancellationToken Structure
See Also Send Feedback

Propogates notification that operations should be canceled.

Namespace: System.Threading
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
<ComVisibleAttribute(False)> _
<HostProtectionAttribute(SecurityAction.LinkDemand, Synchronization := True,  _
    ExternalThreading := True)> _
Public Structure CancellationToken
C#
[ComVisibleAttribute(false)]
[HostProtectionAttribute(SecurityAction.LinkDemand, Synchronization = true,
    ExternalThreading = true)]
public struct CancellationToken

Remarks

A CancellationToken may be created directly in an unchangeable canceled or non-canceled state using the CancellationToken's constructors. However, to have a CancellationToken that can change from a non-canceled to a canceled state, CancellationTokenSource must be used. CancellationTokenSource exposes the associated CancellationToken that may be canceled by the source through its Token property.

Once canceled, a token may not transition to a non-canceled state, and a token whose CanBeCanceled is false will never change to one that can be canceled.

All members of this struct are thread-safe and may be used concurrently from multiple threads.

See Also

System.Threading Namespace


CancellationToken Constructor

[image]

.NET Framework Class Library
CancellationToken Constructor
CancellationToken Structure See Also Send Feedback

Initializes the CancellationToken.

Namespace: System.Threading
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Sub New ( _
    canceled As Boolean _
)
C#
public CancellationToken(
    bool canceled
)

Parameters

canceled
Type: System..::.Boolean
The canceled state for the token.

Remarks

Tokens created with this constructor will remain in the canceled state specified by the canceled parameter. If canceled is false, both CanBeCanceled and IsCancellationRequested will be false. If canceled is true, both CanBeCanceled and IsCancellationRequested will be true.

See Also

CancellationToken Structure
System.Threading Namespace


CancellationToken Methods

[image] [image]

.NET Framework Class Library
CancellationToken Methods
CancellationToken Structure See Also Send Feedback

The CancellationToken type exposes the following members.

Methods

Name | Description
Equals | Overloaded.
Finalize | (Inherited from Object.)
GetHashCode | Serves as a hash function for a CancellationToken. (Overrides ValueType..::.GetHashCode()()().)
GetType | (Inherited from Object.)
MemberwiseClone | (Inherited from Object.)
Register | Overloaded.
ThrowIfCancellationRequested | Throws a OperationCanceledException if this token has had cancellation requested.
ToString | (Inherited from ValueType.)

Operators

Name | Description
Equality | Determines whether two CancellationToken instances are equal.
Inequality | Determines whether two CancellationToken instances are not equal.

See Also

CancellationToken Structure
System.Threading Namespace


Equality Operator

[image]

.NET Framework Class Library
CancellationToken..::.Equality Operator
CancellationToken Structure See Also Send Feedback

Determines whether two CancellationToken instances are equal.

Namespace: System.Threading
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Operator = ( _
    left As CancellationToken, _
    right As CancellationToken _
) As Boolean
C#
public static bool operator ==(
    CancellationToken left,
    CancellationToken right
)

Parameters

left
Type: System.Threading..::.CancellationToken
The first instance.
right
Type: System.Threading..::.CancellationToken
The second instance.

Return Value

True if the instances are equal; otherwise, false.

Exceptions

Exception | Condition
System..::.ObjectDisposedException | An associated CancellationTokenSource has been disposed.

See Also

CancellationToken Structure
System.Threading Namespace


Equals Method

[image] [image]

.NET Framework Class Library
CancellationToken..::.Equals Method
CancellationToken Structure See Also Send Feedback

Overload List

Name | Description
Equals(Object) | Determines whether the current CancellationToken instance is equal to the specified Object. (Overrides ValueType..::.Equals(Object).)
Equals(CancellationToken) | Determines whether the current CancellationToken instance is equal to the specified token.

See Also

CancellationToken Structure
System.Threading Namespace


Equals Method (Object)

[image]

.NET Framework Class Library
CancellationToken..::.Equals Method (Object)
CancellationToken Structure See Also Send Feedback

Determines whether the current CancellationToken instance is equal to the specified Object.

Namespace: System.Threading
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Overrides Function Equals ( _
    other As Object _
) As Boolean
C#
public override bool Equals(
    Object other
)

Parameters

other
Type: System..::.Object
The other object to which to compare this instance.

Return Value

True if other is a CancellationToken and if the two instances are equal; otherwise, false. Two tokens are equal if they are associated with the same CancellationTokenSource or if they were both constructed from public CancellationToken constructors and their IsCancellationRequested values are equal.

Exceptions

Exception | Condition
System..::.ObjectDisposedException | An associated CancellationTokenSource has been disposed.

See Also

CancellationToken Structure
Equals Overload
System.Threading Namespace


Equals Method (CancellationToken)

[image]

.NET Framework Class Library
CancellationToken..::.Equals Method (CancellationToken)
CancellationToken Structure See Also Send Feedback

Determines whether the current CancellationToken instance is equal to the specified token.

Namespace: System.Threading
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Function Equals ( _
    other As CancellationToken _
) As Boolean
C#
public bool Equals(
    CancellationToken other
)

Parameters

other
Type: System.Threading..::.CancellationToken
The other CancellationToken to which to compare this instance.

Return Value

True if the instances are equal; otherwise, false. Two tokens are equal if they are associated with the same CancellationTokenSource or if they were both constructed from public CancellationToken constructors and their IsCancellationRequested values are equal.

See Also

CancellationToken Structure
Equals Overload
System.Threading Namespace


GetHashCode Method

[image]

.NET Framework Class Library
CancellationToken..::.GetHashCode Method
CancellationToken Structure See Also Send Feedback

Serves as a hash function for a CancellationToken.

Namespace: System.Threading
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Overrides Function GetHashCode As Integer
C#
public override int GetHashCode()

Return Value

A hash code for the current CancellationToken instance.

See Also

CancellationToken Structure
System.Threading Namespace


Inequality Operator

[image]

.NET Framework Class Library
CancellationToken..::.Inequality Operator
CancellationToken Structure See Also Send Feedback

Determines whether two CancellationToken instances are not equal.

Namespace: System.Threading
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Operator <> ( _
    left As CancellationToken, _
    right As CancellationToken _
) As Boolean
C#
public static bool operator !=(
    CancellationToken left,
    CancellationToken right
)

Parameters

left
Type: System.Threading..::.CancellationToken
The first instance.
right
Type: System.Threading..::.CancellationToken
The second instance.

Return Value

True if the instances are not equal; otherwise, false.

Exceptions

Exception | Condition
System..::.ObjectDisposedException | An associated CancellationTokenSource has been disposed.

See Also

CancellationToken Structure
System.Threading Namespace


Register Method

[image] [image]

.NET Framework Class Library
CancellationToken..::.Register Method
CancellationToken Structure See Also Send Feedback

Overload List

Name | Description
Register(Action) | Registers a delegate that will be called when this CancellationToken is canceled.
Register(Action, Boolean) | Registers a delegate that will be called when this CancellationToken is canceled.
Register(Action<(Of <(Object>)>), Object) | Registers a delegate that will be called when this CancellationToken is canceled.
Register(Action<(Of <(Object>)>), Object, Boolean) | Registers a delegate that will be called when this CancellationToken is canceled.

See Also

CancellationToken Structure
System.Threading Namespace


Register Method (Action)

[image]

.NET Framework Class Library
CancellationToken..::.Register Method (Action)
CancellationToken Structure See Also Send Feedback

Registers a delegate that will be called when this CancellationToken is canceled.

Namespace: System.Threading
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Function Register ( _
    callback As Action _
) As CancellationTokenRegistration
C#
public CancellationTokenRegistration Register(
    Action callback
)

Parameters

callback
Type: System..::.Action
The delegate to be executed when the CancellationToken is canceled.

Return Value

The CancellationTokenRegistration instance that can be used to deregister the callback.

Remarks

If this token is already in the canceled state, the delegate will be run immediately and synchronously. Any exception the delegate generates will be propogated out of this method call.

The current ExecutionContext, if one exists, will be captured along with the delegate and will be used when executing it.

Exceptions

Exception | Condition
System..::.ArgumentNullException | callback is null.
System..::.ObjectDisposedException | The associated CancellationTokenSource has been disposed.

See Also

CancellationToken Structure
Register Overload
System.Threading Namespace


Register Method (Action, Boolean)

[image]

.NET Framework Class Library
CancellationToken..::.Register Method (Action, Boolean)
CancellationToken Structure See Also Send Feedback

Registers a delegate that will be called when this CancellationToken is canceled.

Namespace: System.Threading
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Function Register ( _
    callback As Action, _
    useSynchronizationContext As Boolean _
) As CancellationTokenRegistration
C#
public CancellationTokenRegistration Register(
    Action callback,
    bool useSynchronizationContext
)

Parameters

callback
Type: System..::.Action
The delegate to be executed when the CancellationToken is canceled.
useSynchronizationContext
Type: System..::.Boolean
A Boolean value that indicates whether to capture the current SynchronizationContext and use it when invoking the callback.

Return Value

The CancellationTokenRegistration instance that can be used to deregister the callback.

Remarks

If this token is already in the canceled state, the delegate will be run immediately and synchronously. Any exception the delegate generates will be propogated out of this method call.

The current ExecutionContext, if one exists, will be captured along with the delegate and will be used when executing it.

Exceptions

Exception | Condition
System..::.ArgumentNullException | callback is null.
System..::.ObjectDisposedException | The associated CancellationTokenSource has been disposed.

See Also

CancellationToken Structure
Register Overload
System.Threading Namespace


Register Method (Action(Object), Object)

[image]

.NET Framework Class Library
CancellationToken..::.Register Method (Action<(Of <(Object>)>), Object)
CancellationToken Structure See Also Send Feedback

Registers a delegate that will be called when this CancellationToken is canceled.

Namespace: System.Threading
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Function Register ( _
    callback As Action(Of Object), _
    state As Object _
) As CancellationTokenRegistration
C#
public CancellationTokenRegistration Register(
    Action<Object> callback,
    Object state
)

Parameters

callback
Type: System..::.Action<(Of <(Object>)>)
The delegate to be executed when the CancellationToken is canceled.
state
Type: System..::.Object
The state to pass to the callback when the delegate is invoked. This may be null.

Return Value

The CancellationTokenRegistration instance that can be used to deregister the callback.

Remarks

If this token is already in the canceled state, the delegate will be run immediately and synchronously. Any exception the delegate generates will be propogated out of this method call.

The current ExecutionContext, if one exists, will be captured along with the delegate and will be used when executing it.

Exceptions

Exception | Condition
System..::.ArgumentNullException | callback is null.
System..::.ObjectDisposedException | The associated CancellationTokenSource has been disposed.

See Also

CancellationToken Structure
Register Overload
System.Threading Namespace


Register Method (Action(Object), Object, Boolean)

[image]

.NET Framework Class Library
CancellationToken..::.Register Method (Action<(Of <(Object>)>), Object, Boolean)
CancellationToken Structure See Also Send Feedback

Registers a delegate that will be called when this CancellationToken is canceled.

Namespace: System.Threading
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Function Register ( _
    callback As Action(Of Object), _
    state As Object, _
    useSynchronizationContext As Boolean _
) As CancellationTokenRegistration
C#
public CancellationTokenRegistration Register(
    Action<Object> callback,
    Object state,
    bool useSynchronizationContext
)

Parameters

callback
Type: System..::.Action<(Of <(Object>)>)
The delegate to be executed when the CancellationToken is canceled.
state
Type: System..::.Object
The state to pass to the callback when the delegate is invoked. This may be null.
useSynchronizationContext
Type: System..::.Boolean
A Boolean value that indicates whether to capture the current SynchronizationContext and use it when invoking the callback.

Return Value

The CancellationTokenRegistration instance that can be used to deregister the callback.

Remarks

If this token is already in the canceled state, the delegate will be run immediately and synchronously. Any exception the delegate generates will be propogated out of this method call.

The current ExecutionContext, if one exists, will be captured along with the delegate and will be used when executing it.

Exceptions

Exception | Condition
System..::.ArgumentNullException | callback is null.
System..::.ObjectDisposedException | The associated CancellationTokenSource has been disposed.

See Also

CancellationToken Structure
Register Overload
System.Threading Namespace


ThrowIfCancellationRequested Method

[image]

.NET Framework Class Library
CancellationToken..::.ThrowIfCancellationRequested Method
CancellationToken Structure See Also Send Feedback

Throws a OperationCanceledException if this token has had cancellation requested.

Namespace: System.Threading
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Sub ThrowIfCancellationRequested
C#
public void ThrowIfCancellationRequested()

Remarks

This method provides functionality equivalent to:
Copy Code
            if (token.IsCancellationRequested)
               throw new OperationCanceledException(token);

Exceptions

Exception | Condition
System..::.OperationCanceledException | The token has had cancellation requested.
System..::.ObjectDisposedException | The associated CancellationTokenSource has been disposed.

See Also

CancellationToken Structure
System.Threading Namespace


CancellationToken Properties

[image] [image]

.NET Framework Class Library
CancellationToken Properties
CancellationToken Structure See Also Send Feedback

The CancellationToken type exposes the following members.

Properties

Name | Description
CanBeCanceled | Gets whether this token is capable of being in the canceled state.
IsCancellationRequested | Gets whether cancellation has been requested for this token.
None | Returns an empty CancellationToken value.
WaitHandle | Gets a WaitHandle that is signaled when the token is canceled.

See Also

CancellationToken Structure
System.Threading Namespace


CanBeCanceled Property

[image]

.NET Framework Class Library
CancellationToken..::.CanBeCanceled Property
CancellationToken Structure See Also Send Feedback

Gets whether this token is capable of being in the canceled state.

Namespace: System.Threading
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public ReadOnly Property CanBeCanceled As Boolean
C#
public bool CanBeCanceled { get; }

Remarks

If CanBeCanceled returns false, it is guaranteed that the token will never transition into a canceled state, meaning that IsCancellationRequested will never return true.

See Also

CancellationToken Structure
System.Threading Namespace


IsCancellationRequested Property

[image]

.NET Framework Class Library
CancellationToken..::.IsCancellationRequested Property
CancellationToken Structure See Also Send Feedback

Gets whether cancellation has been requested for this token.

Namespace: System.Threading
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public ReadOnly Property IsCancellationRequested As Boolean
C#
public bool IsCancellationRequested { get; }

Field Value

Whether cancellation has been requested for this token.

Remarks

This property indicates whether cancellation has been requested for this token, either through the token initially being construted in a canceled state, or through calling Cancel on the token's associated CancellationTokenSource.

If this property is true, it only guarantees that cancellation has been requested. It does not guarantee that every registered handler has finished executing, nor that cancellation requests have finished propagating to all registered handlers. Additional synchronization may be required, particularly in situations where related objects are being canceled concurrently.

See Also

CancellationToken Structure
System.Threading Namespace


None Property

[image]

.NET Framework Class Library
CancellationToken..::.None Property
CancellationToken Structure See Also Send Feedback

Returns an empty CancellationToken value.

Namespace: System.Threading
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared ReadOnly Property None As CancellationToken
C#
public static CancellationToken None { get; }

Remarks

The CancellationToken value returned by this property will be non-cancelable by default.

See Also

CancellationToken Structure
System.Threading Namespace


WaitHandle Property

[image]

.NET Framework Class Library
CancellationToken..::.WaitHandle Property
CancellationToken Structure See Also Send Feedback

Gets a WaitHandle that is signaled when the token is canceled.

Namespace: System.Threading
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public ReadOnly Property WaitHandle As WaitHandle
C#
public WaitHandle WaitHandle { get; }

Remarks

Accessing this property causes a WaitHandle to be instantiated. It is preferable to only use this property when necessary, and to then dispose the associated CancellationTokenSource instance at the earliest opportunity (disposing the source will dispose of this allocated handle). The handle should not be closed or disposed directly.

Exceptions

Exception | Condition
System..::.ObjectDisposedException | The associated CancellationTokenSource has been disposed.

See Also

CancellationToken Structure
System.Threading Namespace


CancellationTokenRegistration Structure

[image]

.NET Framework Class Library
CancellationTokenRegistration Structure
See Also Send Feedback

Represents a callback delegate that has been registered with a CancellationToken.

Namespace: System.Threading
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
<HostProtectionAttribute(SecurityAction.LinkDemand, Synchronization := True,  _
    ExternalThreading := True)> _
Public Structure CancellationTokenRegistration _
    Implements IEquatable(Of CancellationTokenRegistration), IDisposable
C#
[HostProtectionAttribute(SecurityAction.LinkDemand, Synchronization = true,
    ExternalThreading = true)]
public struct CancellationTokenRegistration : IEquatable<CancellationTokenRegistration>,
    IDisposable

Remarks

To unregister a callback, dispose the corresponding Registration instance.

See Also

System.Threading Namespace


CancellationTokenRegistration Methods

[image] [image]

.NET Framework Class Library
CancellationTokenRegistration Methods
CancellationTokenRegistration Structure See Also Send Feedback

The CancellationTokenRegistration type exposes the following members.

Methods

Name | Description
Dispose | Disposes of the registration and unregisters the target callback from the associated CancellationToken. If the target callback is currently executing this method will wait until it completes, except in the degenerate cases where a callback method deregisters itself.
Equals | Overloaded.
Finalize | (Inherited from Object.)
GetHashCode | Serves as a hash function for a CancellationTokenRegistration.. (Overrides ValueType..::.GetHashCode()()().)
GetType | (Inherited from Object.)
MemberwiseClone | (Inherited from Object.)
ToString | (Inherited from ValueType.)

Operators

Name | Description
Equality | Determines whether two CancellationTokenRegistration instances are equal.
Inequality | Determines whether two CancellationTokenRegistration instances are not equal.

See Also

CancellationTokenRegistration Structure
System.Threading Namespace


Dispose Method

[image]

.NET Framework Class Library
CancellationTokenRegistration..::.Dispose Method
CancellationTokenRegistration Structure See Also Send Feedback

Disposes of the registration and unregisters the target callback from the associated CancellationToken. If the target callback is currently executing this method will wait until it completes, except in the degenerate cases where a callback method deregisters itself.

Namespace: System.Threading
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Sub Dispose
C#
public void Dispose()

Implements

IDisposable..::.Dispose()()()

See Also

CancellationTokenRegistration Structure
System.Threading Namespace


Equality Operator

[image]

.NET Framework Class Library
CancellationTokenRegistration..::.Equality Operator
CancellationTokenRegistration Structure See Also Send Feedback

Determines whether two CancellationTokenRegistration instances are equal.

Namespace: System.Threading
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Operator = ( _
    left As CancellationTokenRegistration, _
    right As CancellationTokenRegistration _
) As Boolean
C#
public static bool operator ==(
    CancellationTokenRegistration left,
    CancellationTokenRegistration right
)

Parameters

left
Type: System.Threading..::.CancellationTokenRegistration
The first instance.
right
Type: System.Threading..::.CancellationTokenRegistration
The second instance.

Return Value

True if the instances are equal; otherwise, false.

See Also

CancellationTokenRegistration Structure
System.Threading Namespace


Equals Method

[image] [image]

.NET Framework Class Library
CancellationTokenRegistration..::.Equals Method
CancellationTokenRegistration Structure See Also Send Feedback

Overload List

Name | Description
Equals(Object) | Determines whether the current CancellationTokenRegistration instance is equal to the specified Object. (Overrides ValueType..::.Equals(Object).)
Equals(CancellationTokenRegistration) | Determines whether the current CancellationToken instance is equal to the specified Object.

See Also

CancellationTokenRegistration Structure
System.Threading Namespace


Equals Method (Object)

[image]

.NET Framework Class Library
CancellationTokenRegistration..::.Equals Method (Object)
CancellationTokenRegistration Structure See Also Send Feedback

Determines whether the current CancellationTokenRegistration instance is equal to the specified Object.

Namespace: System.Threading
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Overrides Function Equals ( _
    obj As Object _
) As Boolean
C#
public override bool Equals(
    Object obj
)

Parameters

obj
Type: System..::.Object
The other object to which to compare this instance.

Return Value

True, if both this and obj are equal. False, otherwise. Two CancellationTokenRegistration instances are equal if they both refer to the output of a single call to the same Register method of a CancellationToken.

See Also

CancellationTokenRegistration Structure
Equals Overload
System.Threading Namespace


Equals Method (CancellationTokenRegistration)

[image]

.NET Framework Class Library
CancellationTokenRegistration..::.Equals Method (CancellationTokenRegistration)
CancellationTokenRegistration Structure See Also Send Feedback

Determines whether the current CancellationToken instance is equal to the specified Object.

Namespace: System.Threading
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Function Equals ( _
    other As CancellationTokenRegistration _
) As Boolean
C#
public bool Equals(
    CancellationTokenRegistration other
)

Parameters

other
Type: System.Threading..::.CancellationTokenRegistration
The other CancellationTokenRegistration to which to compare this instance.

Return Value

True, if both this and other are equal. False, otherwise. Two CancellationTokenRegistration instances are equal if they both refer to the output of a single call to the same Register method of a CancellationToken.

Implements

IEquatable<(Of <(T>)>)..::.Equals(T)

See Also

CancellationTokenRegistration Structure
Equals Overload
System.Threading Namespace


GetHashCode Method

[image]

.NET Framework Class Library
CancellationTokenRegistration..::.GetHashCode Method
CancellationTokenRegistration Structure See Also Send Feedback

Serves as a hash function for a CancellationTokenRegistration..

Namespace: System.Threading
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Overrides Function GetHashCode As Integer
C#
public override int GetHashCode()

Return Value

A hash code for the current CancellationTokenRegistration instance.

See Also

CancellationTokenRegistration Structure
System.Threading Namespace


Inequality Operator

[image]

.NET Framework Class Library
CancellationTokenRegistration..::.Inequality Operator
CancellationTokenRegistration Structure See Also Send Feedback

Determines whether two CancellationTokenRegistration instances are not equal.

Namespace: System.Threading
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Operator <> ( _
    left As CancellationTokenRegistration, _
    right As CancellationTokenRegistration _
) As Boolean
C#
public static bool operator !=(
    CancellationTokenRegistration left,
    CancellationTokenRegistration right
)

Parameters

left
Type: System.Threading..::.CancellationTokenRegistration
The first instance.
right
Type: System.Threading..::.CancellationTokenRegistration
The second instance.

Return Value

True if the instances are not equal; otherwise, false.

See Also

CancellationTokenRegistration Structure
System.Threading Namespace


CancellationTokenSource Class

[image]

.NET Framework Class Library
CancellationTokenSource Class
See Also Send Feedback

Signals to a CancellationToken that it should be canceled.

Namespace: System.Threading
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
<ComVisibleAttribute(False)> _
<HostProtectionAttribute(SecurityAction.LinkDemand, Synchronization := True,  _
    ExternalThreading := True)> _
Public NotInheritable Class CancellationTokenSource _
    Implements IDisposable
C#
[ComVisibleAttribute(false)]
[HostProtectionAttribute(SecurityAction.LinkDemand, Synchronization = true,
    ExternalThreading = true)]
public sealed class CancellationTokenSource : IDisposable

Remarks

CancellationTokenSource is used to instantiate a CancellationToken (via the source's Token property) that can be handed to operations that wish to be notified of cancellation or that can be used to register asynchronous operations for cancellation. That token may have cancellation requested by calling to the source's Cancel method.

All members of this class, except Dispose, are thread-safe and may be used concurrently from multiple threads.

Inheritance Hierarchy

System..::.Object
System.Threading..::.CancellationTokenSource

See Also

System.Threading Namespace


CancellationTokenSource Constructor

[image]

.NET Framework Class Library
CancellationTokenSource Constructor
CancellationTokenSource Class See Also Send Feedback

Initializes the CancellationTokenSource.

Namespace: System.Threading
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Sub New
C#
public CancellationTokenSource()

See Also

CancellationTokenSource Class
System.Threading Namespace


CancellationTokenSource Methods

[image] [image]

.NET Framework Class Library
CancellationTokenSource Methods
CancellationTokenSource Class See Also Send Feedback

The CancellationTokenSource type exposes the following members.

Methods

Name | Description
Cancel | Overloaded.
CreateLinkedTokenSource | Overloaded.
Dispose | Releases the resources used by this CancellationTokenSource.
Equals | (Inherited from Object.)
Finalize | (Inherited from Object.)
GetHashCode | (Inherited from Object.)
GetType | (Inherited from Object.)
MemberwiseClone | (Inherited from Object.)
ToString | (Inherited from Object.)

See Also

CancellationTokenSource Class
System.Threading Namespace


Cancel Method

[image] [image]

.NET Framework Class Library
CancellationTokenSource..::.Cancel Method
CancellationTokenSource Class See Also Send Feedback

Overload List

Name | Description
Cancel()()() | Communicates a request for cancellation.
Cancel(Boolean) | Communicates a request for cancellation.

See Also

CancellationTokenSource Class
System.Threading Namespace


Cancel Method

[image]

.NET Framework Class Library
CancellationTokenSource..::.Cancel Method
CancellationTokenSource Class See Also Send Feedback

Communicates a request for cancellation.

Namespace: System.Threading
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Sub Cancel
C#
public void Cancel()

Remarks

The associated CancellationToken will be notified of the cancellation and will transition to a state where IsCancellationRequested returns true. Any callbacks or cancelable operations registered with the CancellationToken will be executed.

Cancelable operations and callbacks registered with the token should not throw exceptions. However, this overload of Cancel will aggregate any exceptions thrown into a AggregateException, such that one callback throwing an exception will not prevent other registered callbacks from being executed.

The ExecutionContext that was captured when each callback was registered will be reestablished when the callback is invoked.

Exceptions

Exception | Condition
System..::.AggregateException | An aggregate exception containing all the exceptions thrown by the registered callbacks on the associated CancellationToken.
System..::.ObjectDisposedException | This CancellationTokenSource has been disposed.

See Also

CancellationTokenSource Class
Cancel Overload
System.Threading Namespace


Cancel Method (Boolean)

[image]

.NET Framework Class Library
CancellationTokenSource..::.Cancel Method (Boolean)
CancellationTokenSource Class See Also Send Feedback

Communicates a request for cancellation.

Namespace: System.Threading
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Sub Cancel ( _
    throwOnFirstException As Boolean _
)
C#
public void Cancel(
    bool throwOnFirstException
)

Parameters

throwOnFirstException
Type: System..::.Boolean
Specifies whether exceptions should immediately propagate.

Remarks

The associated CancellationToken will be notified of the cancellation and will transition to a state where IsCancellationRequested returns true. Any callbacks or cancelable operations registered with the CancellationToken will be executed.

Cancelable operations and callbacks registered with the token should not throw exceptions. If throwOnFirstException is true, an exception will immediately propagate out of the call to Cancel, preventing the remaining callbacks and cancelable operations from being processed. If throwOnFirstException is false, this overload will aggregate any exceptions thrown into a AggregateException, such that one callback throwing an exception will not prevent other registered callbacks from being executed.

The ExecutionContext that was captured when each callback was registered will be reestablished when the callback is invoked.

Exceptions

Exception | Condition
System..::.AggregateException | An aggregate exception containing all the exceptions thrown by the registered callbacks on the associated CancellationToken.
System..::.ObjectDisposedException | This CancellationTokenSource has been disposed.

See Also

CancellationTokenSource Class
Cancel Overload
System.Threading Namespace


CreateLinkedTokenSource Method

[image] [image]

.NET Framework Class Library
CancellationTokenSource..::.CreateLinkedTokenSource Method
CancellationTokenSource Class See Also Send Feedback

Overload List

Name | Description
CreateLinkedTokenSource(array<CancellationToken>[]()[]) | Creates a CancellationTokenSource that will be in the canceled state when any of the source tokens are in the canceled state.
CreateLinkedTokenSource(CancellationToken, CancellationToken) | Creates a CancellationTokenSource that will be in the canceled state when any of the source tokens are in the canceled state.

See Also

CancellationTokenSource Class
System.Threading Namespace


CreateLinkedTokenSource Method (CancellationToken[])

[image]

.NET Framework Class Library
CancellationTokenSource..::.CreateLinkedTokenSource Method (array<CancellationToken>[]()[])
CancellationTokenSource Class See Also Send Feedback

Creates a CancellationTokenSource that will be in the canceled state when any of the source tokens are in the canceled state.

Namespace: System.Threading
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function CreateLinkedTokenSource ( _
    ParamArray tokens As CancellationToken() _
) As CancellationTokenSource
C#
public static CancellationTokenSource CreateLinkedTokenSource(
    params CancellationToken[] tokens
)

Parameters

tokens
Type: array< System.Threading..::.CancellationToken >[]()[]
The CancellationToken instances to observe.

Return Value

A CancellationTokenSource that is linked to the source tokens.

Exceptions

Exception | Condition
System..::.ArgumentNullException | tokens is null.
System..::.ObjectDisposedException | A CancellationTokenSource associated with one of the source tokens has been disposed.

See Also

CancellationTokenSource Class
CreateLinkedTokenSource Overload
System.Threading Namespace


CreateLinkedTokenSource Method (CancellationToken, CancellationToken)

[image]

.NET Framework Class Library
CancellationTokenSource..::.CreateLinkedTokenSource Method (CancellationToken, CancellationToken)
CancellationTokenSource Class See Also Send Feedback

Creates a CancellationTokenSource that will be in the canceled state when any of the source tokens are in the canceled state.

Namespace: System.Threading
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function CreateLinkedTokenSource ( _
    token1 As CancellationToken, _
    token2 As CancellationToken _
) As CancellationTokenSource
C#
public static CancellationTokenSource CreateLinkedTokenSource(
    CancellationToken token1,
    CancellationToken token2
)

Parameters

token1
Type: System.Threading..::.CancellationToken
The first CancellationToken to observe.
token2
Type: System.Threading..::.CancellationToken
The second CancellationToken to observe.

Return Value

A CancellationTokenSource that is linked to the source tokens.

Exceptions

Exception | Condition
System..::.ObjectDisposedException | A CancellationTokenSource associated with one of the source tokens has been disposed.

See Also

CancellationTokenSource Class
CreateLinkedTokenSource Overload
System.Threading Namespace


Dispose Method

[image]

.NET Framework Class Library
CancellationTokenSource..::.Dispose Method
CancellationTokenSource Class See Also Send Feedback

Releases the resources used by this CancellationTokenSource.

Namespace: System.Threading
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Sub Dispose
C#
public void Dispose()

Implements

IDisposable..::.Dispose()()()

Remarks

This method is not thread-safe for any other concurrent calls.

See Also

CancellationTokenSource Class
System.Threading Namespace


CancellationTokenSource Properties

[image] [image]

.NET Framework Class Library
CancellationTokenSource Properties
CancellationTokenSource Class See Also Send Feedback

The CancellationTokenSource type exposes the following members.

Properties

Name | Description
IsCancellationRequested | Gets whether cancellation has been requested for this CancellationTokenSource.
Token | Gets the CancellationToken associated with this CancellationTokenSource.

See Also

CancellationTokenSource Class
System.Threading Namespace


IsCancellationRequested Property

[image]

.NET Framework Class Library
CancellationTokenSource..::.IsCancellationRequested Property
CancellationTokenSource Class See Also Send Feedback

Gets whether cancellation has been requested for this CancellationTokenSource.

Namespace: System.Threading
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public ReadOnly Property IsCancellationRequested As Boolean
C#
public bool IsCancellationRequested { get; }

Field Value

Whether cancellation has been requested for this CancellationTokenSource.

Remarks

This property indicates whether cancellation has been requested for this token source, such as due to a call to its Cancel method.

If this property returns true, it only guarantees that cancellation has been requested. It does not guarantee that every handler registered with the corresponding token has finished executing, nor that cancellation requests have finished propagating to all registered handlers. Additional synchronization may be required, particularly in situations where related objects are being canceled concurrently.

See Also

CancellationTokenSource Class
System.Threading Namespace


Token Property

[image]

.NET Framework Class Library
CancellationTokenSource..::.Token Property
CancellationTokenSource Class See Also Send Feedback

Gets the CancellationToken associated with this CancellationTokenSource.

Namespace: System.Threading
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public ReadOnly Property Token As CancellationToken
C#
public CancellationToken Token { get; }

Field Value

The CancellationToken associated with this CancellationTokenSource.

Exceptions

Exception | Condition
System..::.ObjectDisposedException | The token source has been disposed.

See Also

CancellationTokenSource Class
System.Threading Namespace


CountdownEvent Class

[image]

.NET Framework Class Library
CountdownEvent Class
See Also Send Feedback

Represents a synchronization primitive that is signaled when its count reaches zero.

Namespace: System.Threading
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
<ComVisibleAttribute(False)> _
<HostProtectionAttribute(SecurityAction.LinkDemand, Synchronization := True,  _
    ExternalThreading := True)> _
Public Class CountdownEvent _
    Implements IDisposable
C#
[ComVisibleAttribute(false)]
[HostProtectionAttribute(SecurityAction.LinkDemand, Synchronization = true,
    ExternalThreading = true)]
public class CountdownEvent : IDisposable

Remarks

All public and protected members of CountdownEvent are thread-safe and may be used concurrently from multiple threads, with the exception of Dispose, which must only be used when all other operations on the CountdownEvent have completed, and Reset, which should only be used when no other threads are accessing the event.

Inheritance Hierarchy

System..::.Object
System.Threading..::.CountdownEvent

See Also

System.Threading Namespace


CountdownEvent Constructor

[image]

.NET Framework Class Library
CountdownEvent Constructor
CountdownEvent Class See Also Send Feedback

Initializes a new instance of CountdownEvent class with the specified count.

Namespace: System.Threading
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Sub New ( _
    initialCount As Integer _
)
C#
public CountdownEvent(
    int initialCount
)

Parameters

initialCount
Type: System..::.Int32
The number of signals required to set the CountdownEvent.

Exceptions

Exception | Condition
System..::.ArgumentOutOfRangeException | initialCount is less than 0.

See Also

CountdownEvent Class
System.Threading Namespace


CountdownEvent Methods

[image] [image]

.NET Framework Class Library
CountdownEvent Methods
CountdownEvent Class See Also Send Feedback

The CountdownEvent type exposes the following members.

Methods

Name | Description
AddCount | Overloaded.
Dispose | Overloaded.
Equals | (Inherited from Object.)
Finalize | (Inherited from Object.)
GetHashCode | (Inherited from Object.)
GetType | (Inherited from Object.)
MemberwiseClone | (Inherited from Object.)
Reset | Overloaded.
Signal | Overloaded.
ToString | (Inherited from Object.)
TryAddCount | Overloaded.
Wait | Overloaded.

See Also

CountdownEvent Class
System.Threading Namespace


AddCount Method

[image] [image]

.NET Framework Class Library
CountdownEvent..::.AddCount Method
CountdownEvent Class See Also Send Feedback

Overload List

Name | Description
AddCount()()() | Increments the CountdownEvent's current count by one.
AddCount(Int32) | Increments the CountdownEvent's current count by a specified value.

See Also

CountdownEvent Class
System.Threading Namespace


AddCount Method

[image]

.NET Framework Class Library
CountdownEvent..::.AddCount Method
CountdownEvent Class See Also Send Feedback

Increments the CountdownEvent's current count by one.

Namespace: System.Threading
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Sub AddCount
C#
public void AddCount()

Exceptions

Exception | Condition
System..::.InvalidOperationException | The current instance is already set.
System..::.InvalidOperationException | CurrentCount is equal to MaxValue.
System..::.ObjectDisposedException | The current instance has already been disposed.

See Also

CountdownEvent Class
AddCount Overload
System.Threading Namespace


AddCount Method (Int32)

[image]

.NET Framework Class Library
CountdownEvent..::.AddCount Method (Int32)
CountdownEvent Class See Also Send Feedback

Increments the CountdownEvent's current count by a specified value.

Namespace: System.Threading
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Sub AddCount ( _
    signalCount As Integer _
)
C#
public void AddCount(
    int signalCount
)

Parameters

signalCount
Type: System..::.Int32
The value by which to increase CurrentCount.

Exceptions

Exception | Condition
System..::.ArgumentOutOfRangeException | signalCount is less than 0.
System..::.InvalidOperationException | The current instance is already set.
System..::.InvalidOperationException | CurrentCount is equal to MaxValue.
System..::.ObjectDisposedException | The current instance has already been disposed.

See Also

CountdownEvent Class
AddCount Overload
System.Threading Namespace


Dispose Method

[image] [image]

.NET Framework Class Library
CountdownEvent..::.Dispose Method
CountdownEvent Class See Also Send Feedback

Overload List

Name | Description
Dispose()()() | Releases all resources used by the current instance of CountdownEvent.
Dispose(Boolean) | When overridden in a derived class, releases the unmanaged resources used by the CountdownEvent, and optionally releases the managed resources.

See Also

CountdownEvent Class
System.Threading Namespace


Dispose Method

[image]

.NET Framework Class Library
CountdownEvent..::.Dispose Method
CountdownEvent Class See Also Send Feedback

Releases all resources used by the current instance of CountdownEvent.

Namespace: System.Threading
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Sub Dispose
C#
public void Dispose()

Implements

IDisposable..::.Dispose()()()

Remarks

Unlike most of the members of CountdownEvent, Dispose()()() is not thread-safe and may not be used concurrently with other members of this instance.

See Also

CountdownEvent Class
Dispose Overload
System.Threading Namespace


Dispose Method (Boolean)

[image]

.NET Framework Class Library
CountdownEvent..::.Dispose Method (Boolean)
CountdownEvent Class See Also Send Feedback

When overridden in a derived class, releases the unmanaged resources used by the CountdownEvent, and optionally releases the managed resources.

Namespace: System.Threading
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Protected Overridable Sub Dispose ( _
    disposing As Boolean _
)
C#
protected virtual void Dispose(
    bool disposing
)

Parameters

disposing
Type: System..::.Boolean
true to release both managed and unmanaged resources; false to release only unmanaged resources.

Remarks

Unlike most of the members of CountdownEvent, Dispose()()() is not thread-safe and may not be used concurrently with other members of this instance.

See Also

CountdownEvent Class
Dispose Overload
System.Threading Namespace


Reset Method

[image] [image]

.NET Framework Class Library
CountdownEvent..::.Reset Method
CountdownEvent Class See Also Send Feedback

Overload List

Name | Description
Reset()()() | Resets the CurrentCount to the value of InitialCount.
Reset(Int32) | Resets the CurrentCount to a specified value.

See Also

CountdownEvent Class
System.Threading Namespace


Reset Method

[image]

.NET Framework Class Library
CountdownEvent..::.Reset Method
CountdownEvent Class See Also Send Feedback

Resets the CurrentCount to the value of InitialCount.

Namespace: System.Threading
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Sub Reset
C#
public void Reset()

Remarks

Unlike most of the members of CountdownEvent, Reset is not thread-safe and may not be used concurrently with other members of this instance.

Exceptions

Exception | Condition
System..::.ObjectDisposedException | The current instance has already been disposed..

See Also

CountdownEvent Class
Reset Overload
System.Threading Namespace


Reset Method (Int32)

[image]

.NET Framework Class Library
CountdownEvent..::.Reset Method (Int32)
CountdownEvent Class See Also Send Feedback

Resets the CurrentCount to a specified value.

Namespace: System.Threading
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Sub Reset ( _
    count As Integer _
)
C#
public void Reset(
    int count
)

Parameters

count
Type: System..::.Int32
The number of signals required to set the CountdownEvent.

Remarks

Unlike most of the members of CountdownEvent, Reset is not thread-safe and may not be used concurrently with other members of this instance.

Exceptions

Exception | Condition
System..::.ArgumentOutOfRangeException | count is less than 0.
System..::.ObjectDisposedException | The current instance has alread been disposed.

See Also

CountdownEvent Class
Reset Overload
System.Threading Namespace


Signal Method

[image] [image]

.NET Framework Class Library
CountdownEvent..::.Signal Method
CountdownEvent Class See Also Send Feedback

Overload List

Name | Description
Signal()()() | Registers a signal with the CountdownEvent, decrementing its count.
Signal(Int32) | Registers multiple signals with the CountdownEvent, decrementing its count by the specified amount.

See Also

CountdownEvent Class
System.Threading Namespace


Signal Method

[image]

.NET Framework Class Library
CountdownEvent..::.Signal Method
CountdownEvent Class See Also Send Feedback

Registers a signal with the CountdownEvent, decrementing its count.

Namespace: System.Threading
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Function Signal As Boolean
C#
public bool Signal()

Return Value

true if the signal caused the count to reach zero and the event was set; otherwise, false.

Exceptions

Exception | Condition
System..::.InvalidOperationException | The current instance is already set.
System..::.ObjectDisposedException | The current instance has already been disposed.

See Also

CountdownEvent Class
Signal Overload
System.Threading Namespace


Signal Method (Int32)

[image]

.NET Framework Class Library
CountdownEvent..::.Signal Method (Int32)
CountdownEvent Class See Also Send Feedback

Registers multiple signals with the CountdownEvent, decrementing its count by the specified amount.

Namespace: System.Threading
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Function Signal ( _
    signalCount As Integer _
) As Boolean
C#
public bool Signal(
    int signalCount
)

Parameters

signalCount
Type: System..::.Int32
The number of signals to register.

Return Value

true if the signals caused the count to reach zero and the event was set; otherwise, false.

Exceptions

Exception | Condition
System..::.InvalidOperationException | The current instance is already set. -or- Or signalCount is greater than CurrentCount.
System..::.ArgumentOutOfRangeException | signalCount is less than 1.
System..::.ObjectDisposedException | The current instance has already been disposed.

See Also

CountdownEvent Class
Signal Overload
System.Threading Namespace


TryAddCount Method

[image] [image]

.NET Framework Class Library
CountdownEvent..::.TryAddCount Method
CountdownEvent Class See Also Send Feedback

Overload List

Name | Description
TryAddCount()()() | Attempts to increment the CountdownEvent's current count by one.
TryAddCount(Int32) | Attempts to increment the CountdownEvent's current count by a specified value.

See Also

CountdownEvent Class
System.Threading Namespace


TryAddCount Method

[image]

.NET Framework Class Library
CountdownEvent..::.TryAddCount Method
CountdownEvent Class See Also Send Feedback

Attempts to increment the CountdownEvent's current count by one.

Namespace: System.Threading
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Function TryAddCount As Boolean
C#
public bool TryAddCount()

Return Value

true if the increment succeeded; otherwise, false. If CurrentCount is already at zero. this will return false.

Exceptions

Exception | Condition
System..::.InvalidOperationException | CurrentCount is equal to MaxValue.
System..::.ObjectDisposedException | The current instance has already been disposed.

See Also

CountdownEvent Class
TryAddCount Overload
System.Threading Namespace


TryAddCount Method (Int32)

[image]

.NET Framework Class Library
CountdownEvent..::.TryAddCount Method (Int32)
CountdownEvent Class See Also Send Feedback

Attempts to increment the CountdownEvent's current count by a specified value.

Namespace: System.Threading
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Function TryAddCount ( _
    signalCount As Integer _
) As Boolean
C#
public bool TryAddCount(
    int signalCount
)

Parameters

signalCount
Type: System..::.Int32
The value by which to increase CurrentCount.

Return Value

true if the increment succeeded; otherwise, false. If CurrentCount is already at zero this will return false.

Exceptions

Exception | Condition
System..::.ArgumentOutOfRangeException | signalCount is less than 0.
System..::.InvalidOperationException | The current instance is already set.
System..::.InvalidOperationException | CurrentCount is equal to MaxValue.
System..::.ObjectDisposedException | The current instance has already been disposed.

See Also

CountdownEvent Class
TryAddCount Overload
System.Threading Namespace


Wait Method

[image] [image]

.NET Framework Class Library
CountdownEvent..::.Wait Method
CountdownEvent Class See Also Send Feedback

Overload List

Name | Description
Wait()()() | Blocks the current thread until the CountdownEvent is set.
Wait(Int32) | Blocks the current thread until the CountdownEvent is set, using a 32-bit signed integer to measure the time interval.
Wait(CancellationToken) | Blocks the current thread until the CountdownEvent is set, while observing a CancellationToken.
Wait(TimeSpan) | Blocks the current thread until the CountdownEvent is set, using a TimeSpan to measure the time interval.
Wait(Int32, CancellationToken) | Blocks the current thread until the CountdownEvent is set, using a 32-bit signed integer to measure the time interval, while observing a CancellationToken.
Wait(TimeSpan, CancellationToken) | Blocks the current thread until the CountdownEvent is set, using a TimeSpan to measure the time interval, while observing a CancellationToken.

See Also

CountdownEvent Class
System.Threading Namespace


Wait Method

[image]

.NET Framework Class Library
CountdownEvent..::.Wait Method
CountdownEvent Class See Also Send Feedback

Blocks the current thread until the CountdownEvent is set.

Namespace: System.Threading
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Sub Wait
C#
public void Wait()

Remarks

The caller of this method blocks indefinitely until the current instance is set. The caller will return immediately if the event is currently in a set state.

Exceptions

Exception | Condition
System..::.ObjectDisposedException | The current instance has already been disposed.

See Also

CountdownEvent Class
Wait Overload
System.Threading Namespace


Wait Method (Int32)

[image]

.NET Framework Class Library
CountdownEvent..::.Wait Method (Int32)
CountdownEvent Class See Also Send Feedback

Blocks the current thread until the CountdownEvent is set, using a 32-bit signed integer to measure the time interval.

Namespace: System.Threading
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Function Wait ( _
    millisecondsTimeout As Integer _
) As Boolean
C#
public bool Wait(
    int millisecondsTimeout
)

Parameters

millisecondsTimeout
Type: System..::.Int32
The number of milliseconds to wait, or Infinite(-1) to wait indefinitely.

Return Value

true if the CountdownEvent was set; otherwise, false.

Exceptions

Exception | Condition
System..::.ArgumentOutOfRangeException | millisecondsTimeout is a negative number other than -1, which represents an infinite time-out.
System..::.ObjectDisposedException | The current instance has already been disposed.

See Also

CountdownEvent Class
Wait Overload
System.Threading Namespace


Wait Method (CancellationToken)

[image]

.NET Framework Class Library
CountdownEvent..::.Wait Method (CancellationToken)
CountdownEvent Class See Also Send Feedback

Blocks the current thread until the CountdownEvent is set, while observing a CancellationToken.

Namespace: System.Threading
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Sub Wait ( _
    cancellationToken As CancellationToken _
)
C#
public void Wait(
    CancellationToken cancellationToken
)

Parameters

cancellationToken
Type: System.Threading..::.CancellationToken
The CancellationToken to observe.

Remarks

The caller of this method blocks indefinitely until the current instance is set. The caller will return immediately if the event is currently in a set state. If the CancellationToken being observed is canceled during the wait operation, an OperationCanceledException will be thrown.

Exceptions

Exception | Condition
System..::.OperationCanceledException | cancellationToken has been canceled.
System..::.ObjectDisposedException | The current instance has already been disposed.

See Also

CountdownEvent Class
Wait Overload
System.Threading Namespace


Wait Method (TimeSpan)

[image]

.NET Framework Class Library
CountdownEvent..::.Wait Method (TimeSpan)
CountdownEvent Class See Also Send Feedback

Blocks the current thread until the CountdownEvent is set, using a TimeSpan to measure the time interval.

Namespace: System.Threading
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Function Wait ( _
    timeout As TimeSpan _
) As Boolean
C#
public bool Wait(
    TimeSpan timeout
)

Parameters

timeout
Type: System..::.TimeSpan
A TimeSpan that represents the number of milliseconds to wait, or a TimeSpan that represents -1 milliseconds to wait indefinitely.

Return Value

true if the CountdownEvent was set; otherwise, false.

Exceptions

Exception | Condition
System..::.ArgumentOutOfRangeException | timeout is a negative number other than -1 milliseconds, which represents an infinite time-out -or- timeout is greater than MaxValue.
System..::.ObjectDisposedException | The current instance has already been disposed.

See Also

CountdownEvent Class
Wait Overload
System.Threading Namespace


Wait Method (Int32, CancellationToken)

[image]

.NET Framework Class Library
CountdownEvent..::.Wait Method (Int32, CancellationToken)
CountdownEvent Class See Also Send Feedback

Blocks the current thread until the CountdownEvent is set, using a 32-bit signed integer to measure the time interval, while observing a CancellationToken.

Namespace: System.Threading
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Function Wait ( _
    millisecondsTimeout As Integer, _
    cancellationToken As CancellationToken _
) As Boolean
C#
public bool Wait(
    int millisecondsTimeout,
    CancellationToken cancellationToken
)

Parameters

millisecondsTimeout
Type: System..::.Int32
The number of milliseconds to wait, or Infinite(-1) to wait indefinitely.
cancellationToken
Type: System.Threading..::.CancellationToken
The CancellationToken to observe.

Return Value

true if the CountdownEvent was set; otherwise, false.

Exceptions

Exception | Condition
System..::.ArgumentOutOfRangeException | millisecondsTimeout is a negative number other than -1, which represents an infinite time-out.
System..::.ObjectDisposedException | The current instance has already been disposed.
System..::.OperationCanceledException | cancellationToken has been canceled.

See Also

CountdownEvent Class
Wait Overload
System.Threading Namespace


Wait Method (TimeSpan, CancellationToken)

[image]

.NET Framework Class Library
CountdownEvent..::.Wait Method (TimeSpan, CancellationToken)
CountdownEvent Class See Also Send Feedback

Blocks the current thread until the CountdownEvent is set, using a TimeSpan to measure the time interval, while observing a CancellationToken.

Namespace: System.Threading
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Function Wait ( _
    timeout As TimeSpan, _
    cancellationToken As CancellationToken _
) As Boolean
C#
public bool Wait(
    TimeSpan timeout,
    CancellationToken cancellationToken
)

Parameters

timeout
Type: System..::.TimeSpan
A TimeSpan that represents the number of milliseconds to wait, or a TimeSpan that represents -1 milliseconds to wait indefinitely.
cancellationToken
Type: System.Threading..::.CancellationToken
The CancellationToken to observe.

Return Value

true if the CountdownEvent was set; otherwise, false.

Exceptions

Exception | Condition
System..::.ArgumentOutOfRangeException | timeout is a negative number other than -1 milliseconds, which represents an infinite time-out -or- timeout is greater than MaxValue.
System..::.ObjectDisposedException | The current instance has already been disposed.
System..::.OperationCanceledException | cancellationToken has been canceled.

See Also

CountdownEvent Class
Wait Overload
System.Threading Namespace


CountdownEvent Properties

[image] [image]

.NET Framework Class Library
CountdownEvent Properties
CountdownEvent Class See Also Send Feedback

The CountdownEvent type exposes the following members.

Properties

Name | Description
CurrentCount | Gets the number of remaining signals required to set the event.
InitialCount | Gets the numbers of signals initially required to set the event.
IsSet | Determines whether the event is set.
WaitHandle | Gets a WaitHandle that is used to wait for the event to be set.

See Also

CountdownEvent Class
System.Threading Namespace


CurrentCount Property

[image]

.NET Framework Class Library
CountdownEvent..::.CurrentCount Property
CountdownEvent Class See Also Send Feedback

Gets the number of remaining signals required to set the event.

Namespace: System.Threading
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public ReadOnly Property CurrentCount As Integer
C#
public int CurrentCount { get; }

Field Value

The number of remaining signals required to set the event.

See Also

CountdownEvent Class
System.Threading Namespace


InitialCount Property

[image]

.NET Framework Class Library
CountdownEvent..::.InitialCount Property
CountdownEvent Class See Also Send Feedback

Gets the numbers of signals initially required to set the event.

Namespace: System.Threading
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public ReadOnly Property InitialCount As Integer
C#
public int InitialCount { get; }

Field Value

The number of signals initially required to set the event.

See Also

CountdownEvent Class
System.Threading Namespace


IsSet Property

[image]

.NET Framework Class Library
CountdownEvent..::.IsSet Property
CountdownEvent Class See Also Send Feedback

Determines whether the event is set.

Namespace: System.Threading
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public ReadOnly Property IsSet As Boolean
C#
public bool IsSet { get; }

Field Value

true if the event is set; otherwise, false.

See Also

CountdownEvent Class
System.Threading Namespace


WaitHandle Property

[image]

.NET Framework Class Library
CountdownEvent..::.WaitHandle Property
CountdownEvent Class See Also Send Feedback

Gets a WaitHandle that is used to wait for the event to be set.

Namespace: System.Threading
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public ReadOnly Property WaitHandle As WaitHandle
C#
public WaitHandle WaitHandle { get; }

Field Value

A WaitHandle that is used to wait for the event to be set.

Remarks

WaitHandle should only be used if it's needed for integration with code bases that rely on having a WaitHandle. If all that's needed is to wait for the CountdownEvent to be set, the Wait()()() method should be preferred.

Exceptions

Exception | Condition
System..::.ObjectDisposedException | The current instance has already been disposed.

See Also

CountdownEvent Class
System.Threading Namespace


LazyInitializer Class

[image]

.NET Framework Class Library
LazyInitializer Class
See Also Send Feedback

Provides lazy initialization routines.

Namespace: System.Threading
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
<HostProtectionAttribute(SecurityAction.LinkDemand, Synchronization := True,  _
    ExternalThreading := True)> _
Public NotInheritable Class LazyInitializer
C#
[HostProtectionAttribute(SecurityAction.LinkDemand, Synchronization = true,
    ExternalThreading = true)]
public static class LazyInitializer

Remarks

These routines avoid needing to allocate a dedicated, lazy-initialization instance, instead using references to ensure targets have been initialized as they are accessed.

Inheritance Hierarchy

System..::.Object
System.Threading..::.LazyInitializer

See Also

System.Threading Namespace


LazyInitializer Methods

[image] [image]

.NET Framework Class Library
LazyInitializer Methods
LazyInitializer Class See Also Send Feedback

Methods

Name | Description
EnsureInitialized | Overloaded.

See Also

LazyInitializer Class
System.Threading Namespace


EnsureInitialized Method

[image] [image]

.NET Framework Class Library
LazyInitializer..::.EnsureInitialized Method
LazyInitializer Class See Also Send Feedback

Overload List

Name | Description
EnsureInitialized<(Of <(T>)>)(T%) | Initializes a target reference type with the type's default constructor if the target has not already been initialized.
EnsureInitialized<(Of <(T>)>)(T%, Func<(Of <(T>)>)) | Initializes a target reference type using the specified function if it has not already been initialized.
EnsureInitialized<(Of <(T>)>)(T%, Boolean%, Object%) | Initializes a target reference or value type with its default constructor if it has not already been initialized.
EnsureInitialized<(Of <(T>)>)(T%, Boolean%, Object%, Func<(Of <(T>)>)) | Initializes a target reference or value type with a specified function if it has not already been initialized.

See Also

LazyInitializer Class
System.Threading Namespace


EnsureInitialized(T) Method (T)

[image]

.NET Framework Class Library
LazyInitializer..::.EnsureInitialized<(Of <(T>)>) Method (T%)
LazyInitializer Class See Also Send Feedback

Initializes a target reference type with the type's default constructor if the target has not already been initialized.

Namespace: System.Threading
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function EnsureInitialized(Of T As Class) ( _
    ByRef target As T _
) As T
C#
public static T EnsureInitialized<T>(
    ref T target
)
where T : class

Parameters

target
Type: T %
A reference of type T to initialize if it has not already been initialized.

Type Parameters

T
The refence type of the reference to be initialized.

Return Value

The initialized reference of type T.

Remarks

This method may only be used on reference types. To ensure initialization of value types, see other overloads of EnsureInitialized.

This method may be used concurrently by multiple threads to initialize target. In the event that multiple threads access this method concurrently, multiple instances of T may be created, but only one will be stored into target. In such an occurrence, this method will not dispose of the objects that were not stored. If such objects must be disposed, it is up to the caller to determine if an object was not used and to then dispose of the object appropriately.

Exceptions

Exception | Condition
System..::.MissingMemberException | Type T does not have a default constructor.
System..::.MemberAccessException | Permissions to access the constructor of type T were missing.

See Also

LazyInitializer Class
EnsureInitialized Overload
System.Threading Namespace


EnsureInitialized(T) Method (T, Func(T))

[image]

.NET Framework Class Library
LazyInitializer..::.EnsureInitialized<(Of <(T>)>) Method (T%, Func<(Of <(T>)>))
LazyInitializer Class See Also Send Feedback

Initializes a target reference type using the specified function if it has not already been initialized.

Namespace: System.Threading
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function EnsureInitialized(Of T As Class) ( _
    ByRef target As T, _
    valueFactory As Func(Of T) _
) As T
C#
public static T EnsureInitialized<T>(
    ref T target,
    Func<T> valueFactory
)
where T : class

Parameters

target
Type: T %
The reference of type T to initialize if it has not already been initialized.
valueFactory
Type: System..::.Func<(Of <(T>)>)
The Func<(Of <(T>)>) invoked to initialize the reference.

Type Parameters

T
The reference type of the reference to be initialized.

Return Value

The initialized reference of type T.

Remarks

This method may only be used on reference types, and valueFactory may not return a null reference (Nothing in Visual Basic). To ensure initialization of value types or to allow null reference types, see other overloads of EnsureInitialized.

This method may be used concurrently by multiple threads to initialize target. In the event that multiple threads access this method concurrently, multiple instances of T may be created, but only one will be stored into target. In such an occurrence, this method will not dispose of the objects that were not stored. If such objects must be disposed, it is up to the caller to determine if an object was not used and to then dispose of the object appropriately.

Exceptions

Exception | Condition
System..::.MissingMemberException | Type T does not have a default constructor.
System..::.InvalidOperationException | valueFactory returned null.

See Also

LazyInitializer Class
EnsureInitialized Overload
System.Threading Namespace


EnsureInitialized(T) Method (T, Boolean, Object)

[image]

.NET Framework Class Library
LazyInitializer..::.EnsureInitialized<(Of <(T>)>) Method (T%, Boolean%, Object%)
LazyInitializer Class See Also Send Feedback

Initializes a target reference or value type with its default constructor if it has not already been initialized.

Namespace: System.Threading
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function EnsureInitialized(Of T) ( _
    ByRef target As T, _
    ByRef initialized As Boolean, _
    ByRef syncLock As Object _
) As T
C#
public static T EnsureInitialized<T>(
    ref T target,
    ref bool initialized,
    ref Object syncLock
)

Parameters

target
Type: T %
A reference or value of type T to initialize if it has not already been initialized.
initialized
Type: System..::.Boolean %
A reference to a boolean that determines whether the target has already been initialized.
syncLock
Type: System..::.Object %
A reference to an object used as the mutually exclusive lock for initializing target.

Type Parameters

T
The type of the reference to be initialized.

Return Value

The initialized value of type T.

See Also

LazyInitializer Class
EnsureInitialized Overload
System.Threading Namespace


EnsureInitialized(T) Method (T, Boolean, Object, Func(T))

[image]

.NET Framework Class Library
LazyInitializer..::.EnsureInitialized<(Of <(T>)>) Method (T%, Boolean%, Object%, Func<(Of <(T>)>))
LazyInitializer Class See Also Send Feedback

Initializes a target reference or value type with a specified function if it has not already been initialized.

Namespace: System.Threading
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function EnsureInitialized(Of T) ( _
    ByRef target As T, _
    ByRef initialized As Boolean, _
    ByRef syncLock As Object, _
    valueFactory As Func(Of T) _
) As T
C#
public static T EnsureInitialized<T>(
    ref T target,
    ref bool initialized,
    ref Object syncLock,
    Func<T> valueFactory
)

Parameters

target
Type: T %
A reference or value of type T to initialize if it has not already been initialized.
initialized
Type: System..::.Boolean %
A reference to a boolean that determines whether the target has already been initialized.
syncLock
Type: System..::.Object %
A reference to an object used as the mutually exclusive lock for initializing target.
valueFactory
Type: System..::.Func<(Of <(T>)>)
The Func<(Of <(T>)>) invoked to initialize the reference or value.

Type Parameters

T
The type of the reference to be initialized.

Return Value

The initialized value of type T.

See Also

LazyInitializer Class
EnsureInitialized Overload
System.Threading Namespace


LazyThreadSafetyMode Enumeration

[image]

.NET Framework Class Library
LazyThreadSafetyMode Enumeration
See Also Send Feedback

Specifies how a Lazy<(Of <(T>)>) instance should synchronize access among multiple threads.

Namespace: System.Threading
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Enumeration LazyThreadSafetyMode
C#
public enum LazyThreadSafetyMode

Members

Member name | Description
None | This mode makes no guarantees around the thread-safety of the Lazy<(Of <(T>)>) instance. If used from multiple threads, the behavior of the Lazy<(Of <(T>)>) is undefined. This mode should be used when a Lazy<(Of <(T>)>) is guaranteed to never be initialized from more than one thread simultaneously and high performance is crucial. If valueFactory throws an exception when the Lazy<(Of <(T>)>) is initialized, the exception will be cached and returned on subsequent accesses to Value. Also, if valueFactory recursively accesses Value on this Lazy<(Of <(T>)>) instance, a InvalidOperationException will be thrown.
PublicationOnly | When multiple threads attempt to simultaneously initialize a Lazy<(Of <(T>)>) instance, this mode allows each thread to execute the valueFactory but only the first thread to complete initialization will be allowed to set the final value of the Lazy<(Of <(T>)>). Once initialized successfully, any future calls to Value will return the cached result. If valueFactory throws an exception on any thread, that exception will be propagated out of Value. If any thread executes valueFactory without throwing an exception and, therefore, successfully sets the value, that value will be returned on subsequent accesses to Value from any thread. If no thread succeeds in setting the value, IsValueCreated will remain false and subsequent accesses to Value will result in the valueFactory delegate re-executing. Also, if valueFactory recursively accesses Value on this Lazy<(Of <(T>)>) instance, an exception will NOT be thrown.
ExecutionAndPublication | This mode uses locks to ensure that only a single thread can initialize a Lazy<(Of <(T>)>) instance in a thread-safe manner. In general, taken if this mode is used in conjunction with a Lazy<(Of <(T>)>) valueFactory delegate that uses locks internally, a deadlock can occur if not handled carefully. If valueFactory throws an exception when theLazy<(Of <(T>)>) is initialized, the exception will be cached and returned on subsequent accesses to Value. Also, if valueFactory recursively accesses Value on this Lazy<(Of <(T>)>) instance, a InvalidOperationException will be thrown.

See Also

System.Threading Namespace


ManualResetEventSlim Class

[image]

.NET Framework Class Library
ManualResetEventSlim Class
See Also Send Feedback

Provides a slimmed down version of ManualResetEvent.

Namespace: System.Threading
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
<ComVisibleAttribute(False)> _
<HostProtectionAttribute(SecurityAction.LinkDemand, Synchronization := True,  _
    ExternalThreading := True)> _
Public Class ManualResetEventSlim _
    Implements IDisposable
C#
[ComVisibleAttribute(false)]
[HostProtectionAttribute(SecurityAction.LinkDemand, Synchronization = true,
    ExternalThreading = true)]
public class ManualResetEventSlim : IDisposable

Remarks

All public and protected members of ManualResetEventSlim are thread-safe and may be used concurrently from multiple threads, with the exception of Dispose, which must only be used when all other operations on the ManualResetEventSlim have completed, and Reset, which should only be used when no other threads are accessing the event.

Inheritance Hierarchy

System..::.Object
System.Threading..::.ManualResetEventSlim

See Also

System.Threading Namespace


ManualResetEventSlim Constructor

[image] [image]

.NET Framework Class Library
ManualResetEventSlim Constructor
ManualResetEventSlim Class See Also Send Feedback

Overload List

Name | Description
ManualResetEventSlim()()() | Initializes a new instance of the ManualResetEventSlim class with an initial state of nonsignaled.
ManualResetEventSlim(Boolean) | Initializes a new instance of the ManualResetEventSlim class with a Boolen value indicating whether to set the intial state to signaled.
ManualResetEventSlim(Boolean, Int32) | Initializes a new instance of the ManualResetEventSlim class with a Boolen value indicating whether to set the intial state to signaled and a specified spin count.

See Also

ManualResetEventSlim Class
System.Threading Namespace


ManualResetEventSlim Constructor

[image]

.NET Framework Class Library
ManualResetEventSlim Constructor
ManualResetEventSlim Class See Also Send Feedback

Initializes a new instance of the ManualResetEventSlim class with an initial state of nonsignaled.

Namespace: System.Threading
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Sub New
C#
public ManualResetEventSlim()

See Also

ManualResetEventSlim Class
ManualResetEventSlim Overload
System.Threading Namespace


ManualResetEventSlim Constructor (Boolean)

[image]

.NET Framework Class Library
ManualResetEventSlim Constructor (Boolean)
ManualResetEventSlim Class See Also Send Feedback

Initializes a new instance of the ManualResetEventSlim class with a Boolen value indicating whether to set the intial state to signaled.

Namespace: System.Threading
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Sub New ( _
    initialState As Boolean _
)
C#
public ManualResetEventSlim(
    bool initialState
)

Parameters

initialState
Type: System..::.Boolean
true to set the initial state signaled; false to set the initial state to nonsignaled.

See Also

ManualResetEventSlim Class
ManualResetEventSlim Overload
System.Threading Namespace


ManualResetEventSlim Constructor (Boolean, Int32)

[image]

.NET Framework Class Library
ManualResetEventSlim Constructor (Boolean, Int32)
ManualResetEventSlim Class See Also Send Feedback

Initializes a new instance of the ManualResetEventSlim class with a Boolen value indicating whether to set the intial state to signaled and a specified spin count.

Namespace: System.Threading
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Sub New ( _
    initialState As Boolean, _
    spinCount As Integer _
)
C#
public ManualResetEventSlim(
    bool initialState,
    int spinCount
)

Parameters

initialState
Type: System..::.Boolean
true to set the initial state to signaled; false to set the initial state to nonsignaled.
spinCount
Type: System..::.Int32
The number of spin waits that will occur before falling back to a true wait.

Exceptions

Exception | Condition
System..::.ArgumentOutOfRangeException | spinCount is less than 0 or greater than the maximum allowed value.

See Also

ManualResetEventSlim Class
ManualResetEventSlim Overload
System.Threading Namespace


ManualResetEventSlim Methods

[image] [image]

.NET Framework Class Library
ManualResetEventSlim Methods
ManualResetEventSlim Class See Also Send Feedback

The ManualResetEventSlim type exposes the following members.

Methods

Name | Description
Dispose | Overloaded.
Equals | (Inherited from Object.)
Finalize | (Inherited from Object.)
GetHashCode | (Inherited from Object.)
GetType | (Inherited from Object.)
MemberwiseClone | (Inherited from Object.)
Reset | Sets the state of the event to nonsignaled, which causes threads to block.
Set | Sets the state of the event to signaled, which allows one or more threads waiting on the event to proceed.
ToString | (Inherited from Object.)
Wait | Overloaded.

See Also

ManualResetEventSlim Class
System.Threading Namespace


Dispose Method

[image] [image]

.NET Framework Class Library
ManualResetEventSlim..::.Dispose Method
ManualResetEventSlim Class See Also Send Feedback

Overload List

Name | Description
Dispose()()() | Releases all resources used by the current instance of ManualResetEventSlim.
Dispose(Boolean) | When overridden in a derived class, releases the unmanaged resources used by the ManualResetEventSlim, and optionally releases the managed resources.

See Also

ManualResetEventSlim Class
System.Threading Namespace


Dispose Method

[image]

.NET Framework Class Library
ManualResetEventSlim..::.Dispose Method
ManualResetEventSlim Class See Also Send Feedback

Releases all resources used by the current instance of ManualResetEventSlim.

Namespace: System.Threading
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Sub Dispose
C#
public void Dispose()

Implements

IDisposable..::.Dispose()()()

Remarks

Unlike most of the members of ManualResetEventSlim, Dispose()()() is not thread-safe and may not be used concurrently with other members of this instance.

See Also

ManualResetEventSlim Class
Dispose Overload
System.Threading Namespace


Dispose Method (Boolean)

[image]

.NET Framework Class Library
ManualResetEventSlim..::.Dispose Method (Boolean)
ManualResetEventSlim Class See Also Send Feedback

When overridden in a derived class, releases the unmanaged resources used by the ManualResetEventSlim, and optionally releases the managed resources.

Namespace: System.Threading
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Protected Overridable Sub Dispose ( _
    disposing As Boolean _
)
C#
protected virtual void Dispose(
    bool disposing
)

Parameters

disposing
Type: System..::.Boolean
true to release both managed and unmanaged resources; false to release only unmanaged resources.

Remarks

Unlike most of the members of ManualResetEventSlim, Dispose(Boolean) is not thread-safe and may not be used concurrently with other members of this instance.

See Also

ManualResetEventSlim Class
Dispose Overload
System.Threading Namespace


Reset Method

[image]

.NET Framework Class Library
ManualResetEventSlim..::.Reset Method
ManualResetEventSlim Class See Also Send Feedback

Sets the state of the event to nonsignaled, which causes threads to block.

Namespace: System.Threading
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Sub Reset
C#
public void Reset()

Remarks

Unlike most of the members of ManualResetEventSlim, Reset()()() is not thread-safe and may not be used concurrently with other members of this instance.

See Also

ManualResetEventSlim Class
System.Threading Namespace


Set Method

[image]

.NET Framework Class Library
ManualResetEventSlim..::.Set Method
ManualResetEventSlim Class See Also Send Feedback

Sets the state of the event to signaled, which allows one or more threads waiting on the event to proceed.

Namespace: System.Threading
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Sub Set
C#
public void Set()

See Also

ManualResetEventSlim Class
System.Threading Namespace


Wait Method

[image] [image]

.NET Framework Class Library
ManualResetEventSlim..::.Wait Method
ManualResetEventSlim Class See Also Send Feedback

Overload List

Name | Description
Wait()()() | Blocks the current thread until the current ManualResetEventSlim is set.
Wait(Int32) | Blocks the current thread until the current ManualResetEventSlim is set, using a 32-bit signed integer to measure the time interval.
Wait(CancellationToken) | Blocks the current thread until the current ManualResetEventSlim receives a signal, while observing a CancellationToken.
Wait(TimeSpan) | Blocks the current thread until the current ManualResetEventSlim is set, using a TimeSpan to measure the time interval.
Wait(Int32, CancellationToken) | Blocks the current thread until the current ManualResetEventSlim is set, using a 32-bit signed integer to measure the time interval, while observing a CancellationToken.
Wait(TimeSpan, CancellationToken) | Blocks the current thread until the current ManualResetEventSlim is set, using a TimeSpan to measure the time interval, while observing a CancellationToken.

See Also

ManualResetEventSlim Class
System.Threading Namespace


Wait Method

[image]

.NET Framework Class Library
ManualResetEventSlim..::.Wait Method
ManualResetEventSlim Class See Also Send Feedback

Blocks the current thread until the current ManualResetEventSlim is set.

Namespace: System.Threading
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Sub Wait
C#
public void Wait()

Remarks

The caller of this method blocks indefinitely until the current instance is set. The caller will return immediately if the event is currently in a set state.

Exceptions

Exception | Condition
System..::.InvalidOperationException | The maximum number of waiters has been exceeded.

See Also

ManualResetEventSlim Class
Wait Overload
System.Threading Namespace


Wait Method (Int32)

[image]

.NET Framework Class Library
ManualResetEventSlim..::.Wait Method (Int32)
ManualResetEventSlim Class See Also Send Feedback

Blocks the current thread until the current ManualResetEventSlim is set, using a 32-bit signed integer to measure the time interval.

Namespace: System.Threading
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Function Wait ( _
    millisecondsTimeout As Integer _
) As Boolean
C#
public bool Wait(
    int millisecondsTimeout
)

Parameters

millisecondsTimeout
Type: System..::.Int32
The number of milliseconds to wait, or Infinite(-1) to wait indefinitely.

Return Value

true if the ManualResetEventSlim was set; otherwise, false.

Exceptions

Exception | Condition
System..::.ArgumentOutOfRangeException | millisecondsTimeout is a negative number other than -1, which represents an infinite time-out.
System..::.InvalidOperationException | The maximum number of waiters has been exceeded.

See Also

ManualResetEventSlim Class
Wait Overload
System.Threading Namespace


Wait Method (CancellationToken)

[image]

.NET Framework Class Library
ManualResetEventSlim..::.Wait Method (CancellationToken)
ManualResetEventSlim Class See Also Send Feedback

Blocks the current thread until the current ManualResetEventSlim receives a signal, while observing a CancellationToken.

Namespace: System.Threading
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Sub Wait ( _
    cancellationToken As CancellationToken _
)
C#
public void Wait(
    CancellationToken cancellationToken
)

Parameters

cancellationToken
Type: System.Threading..::.CancellationToken
The CancellationToken to observe.

Remarks

The caller of this method blocks indefinitely until the current instance is set. The caller will return immediately if the event is currently in a set state.

Exceptions

Exception | Condition
System..::.InvalidOperationException | The maximum number of waiters has been exceeded.
OperationCanceledExcepton | cancellationToken was canceled.

See Also

ManualResetEventSlim Class
Wait Overload
System.Threading Namespace


Wait Method (TimeSpan)

[image]

.NET Framework Class Library
ManualResetEventSlim..::.Wait Method (TimeSpan)
ManualResetEventSlim Class See Also Send Feedback

Blocks the current thread until the current ManualResetEventSlim is set, using a TimeSpan to measure the time interval.

Namespace: System.Threading
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Function Wait ( _
    timeout As TimeSpan _
) As Boolean
C#
public bool Wait(
    TimeSpan timeout
)

Parameters

timeout
Type: System..::.TimeSpan
A TimeSpan that represents the number of milliseconds to wait, or a TimeSpan that represents -1 milliseconds to wait indefinitely.

Return Value

true if the ManualResetEventSlim was set; otherwise, false.

Exceptions

Exception | Condition
System..::.ArgumentOutOfRangeException | timeout is a negative number other than -1 milliseconds, which represents an infinite time-out -or- timeout is greater than MaxValue.
System..::.InvalidOperationException | The maximum number of waiters has been exceeded.

See Also

ManualResetEventSlim Class
Wait Overload
System.Threading Namespace


Wait Method (Int32, CancellationToken)

[image]

.NET Framework Class Library
ManualResetEventSlim..::.Wait Method (Int32, CancellationToken)
ManualResetEventSlim Class See Also Send Feedback

Blocks the current thread until the current ManualResetEventSlim is set, using a 32-bit signed integer to measure the time interval, while observing a CancellationToken.

Namespace: System.Threading
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Function Wait ( _
    millisecondsTimeout As Integer, _
    cancellationToken As CancellationToken _
) As Boolean
C#
public bool Wait(
    int millisecondsTimeout,
    CancellationToken cancellationToken
)

Parameters

millisecondsTimeout
Type: System..::.Int32
The number of milliseconds to wait, or Infinite(-1) to wait indefinitely.
cancellationToken
Type: System.Threading..::.CancellationToken
The CancellationToken to observe.

Return Value

true if the ManualResetEventSlim was set; otherwise, false.

Exceptions

Exception | Condition
System..::.ArgumentOutOfRangeException | millisecondsTimeout is a negative number other than -1, which represents an infinite time-out.
System..::.InvalidOperationException | The maximum number of waiters has been exceeded.
OperationCanceledException | cancellationToken was canceled.

See Also

ManualResetEventSlim Class
Wait Overload
System.Threading Namespace


Wait Method (TimeSpan, CancellationToken)

[image]

.NET Framework Class Library
ManualResetEventSlim..::.Wait Method (TimeSpan, CancellationToken)
ManualResetEventSlim Class See Also Send Feedback

Blocks the current thread until the current ManualResetEventSlim is set, using a TimeSpan to measure the time interval, while observing a CancellationToken.

Namespace: System.Threading
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Function Wait ( _
    timeout As TimeSpan, _
    cancellationToken As CancellationToken _
) As Boolean
C#
public bool Wait(
    TimeSpan timeout,
    CancellationToken cancellationToken
)

Parameters

timeout
Type: System..::.TimeSpan
A TimeSpan that represents the number of milliseconds to wait, or a TimeSpan that represents -1 milliseconds to wait indefinitely.
cancellationToken
Type: System.Threading..::.CancellationToken
The CancellationToken to observe.

Return Value

true if the ManualResetEventSlim was set; otherwise, false.

Exceptions

Exception | Condition
System..::.ArgumentOutOfRangeException | timeout is a negative number other than -1 milliseconds, which represents an infinite time-out -or- timeout is greater than MaxValue.
OperationCanceledException | cancellationToken was canceled.
System..::.InvalidOperationException | The maximum number of waiters has been exceeded.

See Also

ManualResetEventSlim Class
Wait Overload
System.Threading Namespace


ManualResetEventSlim Properties

[image] [image]

.NET Framework Class Library
ManualResetEventSlim Properties
ManualResetEventSlim Class See Also Send Feedback

The ManualResetEventSlim type exposes the following members.

Properties

Name | Description
IsSet | Gets whether the event is set.
SpinCount | Gets the number of spin waits that will be occur before falling back to a true wait.
WaitHandle | Gets the underlying WaitHandle object for this ManualResetEventSlim.

See Also

ManualResetEventSlim Class
System.Threading Namespace


IsSet Property

[image]

.NET Framework Class Library
ManualResetEventSlim..::.IsSet Property
ManualResetEventSlim Class See Also Send Feedback

Gets whether the event is set.

Namespace: System.Threading
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Property IsSet As Boolean
C#
public bool IsSet { get; private set; }

Field Value

true if the event has is set; otherwise, false.

See Also

ManualResetEventSlim Class
System.Threading Namespace


SpinCount Property

[image]

.NET Framework Class Library
ManualResetEventSlim..::.SpinCount Property
ManualResetEventSlim Class See Also Send Feedback

Gets the number of spin waits that will be occur before falling back to a true wait.

Namespace: System.Threading
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Property SpinCount As Integer
C#
public int SpinCount { get; private set; }

See Also

ManualResetEventSlim Class
System.Threading Namespace


WaitHandle Property

[image]

.NET Framework Class Library
ManualResetEventSlim..::.WaitHandle Property
ManualResetEventSlim Class See Also Send Feedback

Gets the underlying WaitHandle object for this ManualResetEventSlim.

Namespace: System.Threading
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public ReadOnly Property WaitHandle As WaitHandle
C#
public WaitHandle WaitHandle { get; }

Field Value

The underlying WaitHandle event object fore this ManualResetEventSlim.

Remarks

Accessing this property forces initialization of an underlying event object if one hasn't already been created. To simply wait on this ManualResetEventSlim, the public Wait methods should be preferred.

See Also

ManualResetEventSlim Class
System.Threading Namespace


SemaphoreSlim Class

[image]

.NET Framework Class Library
SemaphoreSlim Class
See Also Send Feedback

Limits the number of threads that can access a resource or pool of resources concurrently.

Namespace: System.Threading
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
<ComVisibleAttribute(False)> _
<HostProtectionAttribute(SecurityAction.LinkDemand, Synchronization := True,  _
    ExternalThreading := True)> _
Public Class SemaphoreSlim _
    Implements IDisposable
C#
[ComVisibleAttribute(false)]
[HostProtectionAttribute(SecurityAction.LinkDemand, Synchronization = true,
    ExternalThreading = true)]
public class SemaphoreSlim : IDisposable

Remarks

The SemaphoreSlim provides a lightweight semaphore class that doesn't use Windows kernel semaphores.

All public and protected members of SemaphoreSlim are thread-safe and may be used concurrently from multiple threads, with the exception of Dispose, which must only be used when all other operations on the SemaphoreSlim have completed.

Inheritance Hierarchy

System..::.Object
System.Threading..::.SemaphoreSlim

See Also

System.Threading Namespace


SemaphoreSlim Constructor

[image] [image]

.NET Framework Class Library
SemaphoreSlim Constructor
SemaphoreSlim Class See Also Send Feedback

Overload List

Name | Description
SemaphoreSlim(Int32) | Initializes a new instance of the SemaphoreSlim class, specifying the initial number of requests that can be granted concurrently.
SemaphoreSlim(Int32, Int32) | Initializes a new instance of the SemaphoreSlim class, specifying the initial and maximum number of requests that can be granted concurrently.

See Also

SemaphoreSlim Class
System.Threading Namespace


SemaphoreSlim Constructor (Int32)

[image]

.NET Framework Class Library
SemaphoreSlim Constructor (Int32)
SemaphoreSlim Class See Also Send Feedback

Initializes a new instance of the SemaphoreSlim class, specifying the initial number of requests that can be granted concurrently.

Namespace: System.Threading
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Sub New ( _
    initialCount As Integer _
)
C#
public SemaphoreSlim(
    int initialCount
)

Parameters

initialCount
Type: System..::.Int32
The initial number of requests for the semaphore that can be granted concurrently.

Exceptions

Exception | Condition
System..::.ArgumentOutOfRangeException | initialCount is less than 0.

See Also

SemaphoreSlim Class
SemaphoreSlim Overload
System.Threading Namespace


SemaphoreSlim Constructor (Int32, Int32)

[image]

.NET Framework Class Library
SemaphoreSlim Constructor (Int32, Int32)
SemaphoreSlim Class See Also Send Feedback

Initializes a new instance of the SemaphoreSlim class, specifying the initial and maximum number of requests that can be granted concurrently.

Namespace: System.Threading
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Sub New ( _
    initialCount As Integer, _
    maxCount As Integer _
)
C#
public SemaphoreSlim(
    int initialCount,
    int maxCount
)

Parameters

initialCount
Type: System..::.Int32
The initial number of requests for the semaphore that can be granted concurrently.
maxCount
Type: System..::.Int32
The maximum number of requests for the semaphore that can be granted concurrently.

Exceptions

Exception | Condition
System..::.ArgumentOutOfRangeException | initialCount is less than 0. -or- initialCount is greater than maxCount. -or- maxCount is less than 0.

See Also

SemaphoreSlim Class
SemaphoreSlim Overload
System.Threading Namespace


SemaphoreSlim Methods

[image] [image]

.NET Framework Class Library
SemaphoreSlim Methods
SemaphoreSlim Class See Also Send Feedback

The SemaphoreSlim type exposes the following members.

Methods

Name | Description
Dispose | Overloaded.
Equals | (Inherited from Object.)
Finalize | (Inherited from Object.)
GetHashCode | (Inherited from Object.)
GetType | (Inherited from Object.)
MemberwiseClone | (Inherited from Object.)
Release | Overloaded.
ToString | (Inherited from Object.)
Wait | Overloaded.

See Also

SemaphoreSlim Class
System.Threading Namespace


Dispose Method

[image] [image]

.NET Framework Class Library
SemaphoreSlim..::.Dispose Method
SemaphoreSlim Class See Also Send Feedback

Overload List

Name | Description
Dispose()()() | Releases all resources used by the current instance of SemaphoreSlim.
Dispose(Boolean) | When overridden in a derived class, releases the unmanaged resources used by the ManualResetEventSlim, and optionally releases the managed resources.

See Also

SemaphoreSlim Class
System.Threading Namespace


Dispose Method

[image]

.NET Framework Class Library
SemaphoreSlim..::.Dispose Method
SemaphoreSlim Class See Also Send Feedback

Releases all resources used by the current instance of SemaphoreSlim.

Namespace: System.Threading
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Sub Dispose
C#
public void Dispose()

Implements

IDisposable..::.Dispose()()()

Remarks

Unlike most of the members of SemaphoreSlim, Dispose()()() is not thread-safe and may not be used concurrently with other members of this instance.

See Also

SemaphoreSlim Class
Dispose Overload
System.Threading Namespace


Dispose Method (Boolean)

[image]

.NET Framework Class Library
SemaphoreSlim..::.Dispose Method (Boolean)
SemaphoreSlim Class See Also Send Feedback

When overridden in a derived class, releases the unmanaged resources used by the ManualResetEventSlim, and optionally releases the managed resources.

Namespace: System.Threading
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Protected Overridable Sub Dispose ( _
    disposing As Boolean _
)
C#
protected virtual void Dispose(
    bool disposing
)

Parameters

disposing
Type: System..::.Boolean
true to release both managed and unmanaged resources; false to release only unmanaged resources.

Remarks

Unlike most of the members of SemaphoreSlim, Dispose(Boolean) is not thread-safe and may not be used concurrently with other members of this instance.

See Also

SemaphoreSlim Class
Dispose Overload
System.Threading Namespace


Release Method

[image] [image]

.NET Framework Class Library
SemaphoreSlim..::.Release Method
SemaphoreSlim Class See Also Send Feedback

Overload List

Name | Description
Release()()() | Exits the SemaphoreSlim once.
Release(Int32) | Exits the SemaphoreSlim a specified number of times.

See Also

SemaphoreSlim Class
System.Threading Namespace


Release Method

[image]

.NET Framework Class Library
SemaphoreSlim..::.Release Method
SemaphoreSlim Class See Also Send Feedback

Exits the SemaphoreSlim once.

Namespace: System.Threading
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Function Release As Integer
C#
public int Release()

Return Value

The previous count of the SemaphoreSlim.

Exceptions

Exception | Condition
System..::.ObjectDisposedException | The current instance has already been disposed.

See Also

SemaphoreSlim Class
Release Overload
System.Threading Namespace


Release Method (Int32)

[image]

.NET Framework Class Library
SemaphoreSlim..::.Release Method (Int32)
SemaphoreSlim Class See Also Send Feedback

Exits the SemaphoreSlim a specified number of times.

Namespace: System.Threading
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Function Release ( _
    releaseCount As Integer _
) As Integer
C#
public int Release(
    int releaseCount
)

Parameters

releaseCount
Type: System..::.Int32
The number of times to exit the semaphore.

Return Value

The previous count of the SemaphoreSlim.

Exceptions

Exception | Condition
System..::.ArgumentOutOfRangeException | releaseCount is less than 1.
System.Threading..::.SemaphoreFullException | The SemaphoreSlim has already reached its maximum size.
System..::.ObjectDisposedException | The current instance has already been disposed.

See Also

SemaphoreSlim Class
Release Overload
System.Threading Namespace


Wait Method

[image] [image]

.NET Framework Class Library
SemaphoreSlim..::.Wait Method
SemaphoreSlim Class See Also Send Feedback

Overload List

Name | Description
Wait()()() | Blocks the current thread until it can enter the SemaphoreSlim.
Wait(Int32) | Blocks the current thread until it can enter the SemaphoreSlim, using a 32-bit signed integer to measure the time interval.
Wait(CancellationToken) | Blocks the current thread until it can enter the SemaphoreSlim, while observing a CancellationToken.
Wait(TimeSpan) | Blocks the current thread until it can enter the SemaphoreSlim, using a TimeSpan to measure the time interval.
Wait(Int32, CancellationToken) | Blocks the current thread until it can enter the SemaphoreSlim, using a 32-bit signed integer to measure the time interval, while observing a CancellationToken.
Wait(TimeSpan, CancellationToken) | Blocks the current thread until it can enter the SemaphoreSlim, using a TimeSpan to measure the time interval, while observing a CancellationToken.

See Also

SemaphoreSlim Class
System.Threading Namespace


Wait Method

[image]

.NET Framework Class Library
SemaphoreSlim..::.Wait Method
SemaphoreSlim Class See Also Send Feedback

Blocks the current thread until it can enter the SemaphoreSlim.

Namespace: System.Threading
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Sub Wait
C#
public void Wait()

Exceptions

Exception | Condition
System..::.ObjectDisposedException | The current instance has already been disposed.

See Also

SemaphoreSlim Class
Wait Overload
System.Threading Namespace


Wait Method (Int32)

[image]

.NET Framework Class Library
SemaphoreSlim..::.Wait Method (Int32)
SemaphoreSlim Class See Also Send Feedback

Blocks the current thread until it can enter the SemaphoreSlim, using a 32-bit signed integer to measure the time interval.

Namespace: System.Threading
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Function Wait ( _
    millisecondsTimeout As Integer _
) As Boolean
C#
public bool Wait(
    int millisecondsTimeout
)

Parameters

millisecondsTimeout
Type: System..::.Int32
The number of milliseconds to wait, or Infinite(-1) to wait indefinitely.

Return Value

true if the current thread successfully entered the SemaphoreSlim; otherwise, false.

Exceptions

Exception | Condition
System..::.ArgumentOutOfRangeException | millisecondsTimeout is a negative number other than -1, which represents an infinite time-out.

See Also

SemaphoreSlim Class
Wait Overload
System.Threading Namespace


Wait Method (CancellationToken)

[image]

.NET Framework Class Library
SemaphoreSlim..::.Wait Method (CancellationToken)
SemaphoreSlim Class See Also Send Feedback

Blocks the current thread until it can enter the SemaphoreSlim, while observing a CancellationToken.

Namespace: System.Threading
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Sub Wait ( _
    cancellationToken As CancellationToken _
)
C#
public void Wait(
    CancellationToken cancellationToken
)

Parameters

cancellationToken
Type: System.Threading..::.CancellationToken
The CancellationToken token to observe.

Exceptions

Exception | Condition
System..::.OperationCanceledException | cancellationToken was canceled.
System..::.ObjectDisposedException | The current instance has already been disposed.

See Also

SemaphoreSlim Class
Wait Overload
System.Threading Namespace


Wait Method (TimeSpan)

[image]

.NET Framework Class Library
SemaphoreSlim..::.Wait Method (TimeSpan)
SemaphoreSlim Class See Also Send Feedback

Blocks the current thread until it can enter the SemaphoreSlim, using a TimeSpan to measure the time interval.

Namespace: System.Threading
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Function Wait ( _
    timeout As TimeSpan _
) As Boolean
C#
public bool Wait(
    TimeSpan timeout
)

Parameters

timeout
Type: System..::.TimeSpan
A TimeSpan that represents the number of milliseconds to wait, or a TimeSpan that represents -1 milliseconds to wait indefinitely.

Return Value

true if the current thread successfully entered the SemaphoreSlim; otherwise, false.

Exceptions

Exception | Condition
System..::.ArgumentOutOfRangeException | timeout is a negative number other than -1 milliseconds, which represents an infinite time-out -or- timeout is greater than MaxValue.

See Also

SemaphoreSlim Class
Wait Overload
System.Threading Namespace


Wait Method (Int32, CancellationToken)

[image]

.NET Framework Class Library
SemaphoreSlim..::.Wait Method (Int32, CancellationToken)
SemaphoreSlim Class See Also Send Feedback

Blocks the current thread until it can enter the SemaphoreSlim, using a 32-bit signed integer to measure the time interval, while observing a CancellationToken.

Namespace: System.Threading
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Function Wait ( _
    millisecondsTimeout As Integer, _
    cancellationToken As CancellationToken _
) As Boolean
C#
public bool Wait(
    int millisecondsTimeout,
    CancellationToken cancellationToken
)

Parameters

millisecondsTimeout
Type: System..::.Int32
The number of milliseconds to wait, or Infinite(-1) to wait indefinitely.
cancellationToken
Type: System.Threading..::.CancellationToken
The CancellationToken to observe.

Return Value

true if the current thread successfully entered the SemaphoreSlim; otherwise, false.

Exceptions

Exception | Condition
System..::.ArgumentOutOfRangeException | millisecondsTimeout is a negative number other than -1, which represents an infinite time-out.
System..::.OperationCanceledException | cancellationToken was canceled.

See Also

SemaphoreSlim Class
Wait Overload
System.Threading Namespace


Wait Method (TimeSpan, CancellationToken)

[image]

.NET Framework Class Library
SemaphoreSlim..::.Wait Method (TimeSpan, CancellationToken)
SemaphoreSlim Class See Also Send Feedback

Blocks the current thread until it can enter the SemaphoreSlim, using a TimeSpan to measure the time interval, while observing a CancellationToken.

Namespace: System.Threading
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Function Wait ( _
    timeout As TimeSpan, _
    cancellationToken As CancellationToken _
) As Boolean
C#
public bool Wait(
    TimeSpan timeout,
    CancellationToken cancellationToken
)

Parameters

timeout
Type: System..::.TimeSpan
A TimeSpan that represents the number of milliseconds to wait, or a TimeSpan that represents -1 milliseconds to wait indefinitely.
cancellationToken
Type: System.Threading..::.CancellationToken
The CancellationToken to observe.

Return Value

true if the current thread successfully entered the SemaphoreSlim; otherwise, false.

Exceptions

Exception | Condition
System..::.ArgumentOutOfRangeException | timeout is a negative number other than -1 milliseconds, which represents an infinite time-out -or- timeout is greater than MaxValue.
System..::.OperationCanceledException | cancellationToken was canceled.

See Also

SemaphoreSlim Class
Wait Overload
System.Threading Namespace


SemaphoreSlim Properties

[image] [image]

.NET Framework Class Library
SemaphoreSlim Properties
SemaphoreSlim Class See Also Send Feedback

The SemaphoreSlim type exposes the following members.

Properties

Name | Description
AvailableWaitHandle | Returns a WaitHandle that can be used to wait on the semaphore.
CurrentCount | Gets the current count of the SemaphoreSlim.

See Also

SemaphoreSlim Class
System.Threading Namespace


AvailableWaitHandle Property

[image]

.NET Framework Class Library
SemaphoreSlim..::.AvailableWaitHandle Property
SemaphoreSlim Class See Also Send Feedback

Returns a WaitHandle that can be used to wait on the semaphore.

Namespace: System.Threading
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public ReadOnly Property AvailableWaitHandle As WaitHandle
C#
public WaitHandle AvailableWaitHandle { get; }

Field Value

A WaitHandle that can be used to wait on the semaphore.

Remarks

A successful wait on the AvailableWaitHandle does not imply a successful wait on the SemaphoreSlim itself, nor does it decrement the semaphore's count. AvailableWaitHandle exists to allow a thread to block waiting on multiple semaphores, but such a wait should be followed by a true wait on the target semaphore.

Exceptions

Exception | Condition
System..::.ObjectDisposedException | The SemaphoreSlim has been disposed.

See Also

SemaphoreSlim Class
System.Threading Namespace


CurrentCount Property

[image]

.NET Framework Class Library
SemaphoreSlim..::.CurrentCount Property
SemaphoreSlim Class See Also Send Feedback

Gets the current count of the SemaphoreSlim.

Namespace: System.Threading
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public ReadOnly Property CurrentCount As Integer
C#
public int CurrentCount { get; }

Field Value

The current count of the SemaphoreSlim.

See Also

SemaphoreSlim Class
System.Threading Namespace


SpinLock Structure

[image]

.NET Framework Class Library
SpinLock Structure
See Also Send Feedback

Provides a mutual exclusion lock primitive where a thread trying to acquire the lock waits in a loop repeatedly checking until the lock becomes available.

Namespace: System.Threading
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
<ComVisibleAttribute(False)> _
<HostProtectionAttribute(SecurityAction.LinkDemand, Synchronization := True,  _
    ExternalThreading := True)> _
Public Structure SpinLock
C#
[ComVisibleAttribute(false)]
[HostProtectionAttribute(SecurityAction.LinkDemand, Synchronization = true,
    ExternalThreading = true)]
public struct SpinLock

Remarks

Spin locks can be used for leaf-level locks where the object allocation implied by using a Monitor, in size or due to garbage collection pressure, is overly expensive. Avoiding blocking is another reason that a spin lock can be useful, however if you expect any significant amount of blocking, you are probably best not using spin locks due to excessive spinning. Spinning can be beneficial when locks are fine grained and large in number (for example, a lock per node in a linked list) as well as when lock hold times are always extremely short. In general, while holding a spin lock, one should avoid blocking, calling anything that itself may block, holding more than one spin lock at once, making dynamically dispatched calls (interface and virtuals), making statically dispatched calls into any code one doesn't own, or allocating memory.

SpinLock should only be used when it's been determined that doing so will improve an application's performance. It's also important to note that SpinLock is a value type, for performance reasons. As such, one must be very careful not to accidentally copy a SpinLock instance, as the two instances (the original and the copy) would then be completely independent of one another, which would likely lead to erroneous behavior of the application. If a SpinLock instance must be passed around, it should be passed by reference rather than by value.

Do not store SpinLock instances in readonly fields.

All members of SpinLock are thread-safe and may be used from multiple threads concurrently.

See Also

System.Threading Namespace


SpinLock Constructor

[image]

.NET Framework Class Library
SpinLock Constructor
SpinLock Structure See Also Send Feedback

Initializes a new instance of the SpinLock structure with the option to track thread IDs to improve debugging.

Namespace: System.Threading
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Sub New ( _
    enableThreadOwnerTracking As Boolean _
)
C#
public SpinLock(
    bool enableThreadOwnerTracking
)

Parameters

enableThreadOwnerTracking
Type: System..::.Boolean
Whether to capture and use thread IDs for debugging purposes.

Remarks

The default constructor for SpinLock tracks thread ownership.

See Also

SpinLock Structure
System.Threading Namespace


SpinLock Methods

[image] [image]

.NET Framework Class Library
SpinLock Methods
SpinLock Structure See Also Send Feedback

The SpinLock type exposes the following members.

Methods

Name | Description
Enter | Initializes a new instance of the SpinLock structure with the option to track thread IDs to improve debugging.
Equals | (Inherited from ValueType.)
Exit | Overloaded.
Finalize | (Inherited from Object.)
GetHashCode | (Inherited from ValueType.)
GetType | (Inherited from Object.)
MemberwiseClone | (Inherited from Object.)
ToString | (Inherited from ValueType.)
TryEnter | Overloaded.

See Also

SpinLock Structure
System.Threading Namespace


Enter Method

[image]

.NET Framework Class Library
SpinLock..::.Enter Method
SpinLock Structure See Also Send Feedback

Initializes a new instance of the SpinLock structure with the option to track thread IDs to improve debugging.
Acquires the lock in a reliable manner, such that even if an exception occurs within the method call, lockTaken can be examined reliably to determine whether the lock was acquired.

Namespace: System.Threading
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Sub Enter ( _
    ByRef lockTaken As Boolean _
)
C#
public void Enter(
    ref bool lockTaken
)

Parameters

lockTaken
Type: System..::.Boolean %
True if the lock is acquired; otherwise, false. lockTaken must be initialized to false prior to calling this method.

Remarks

The default constructor for SpinLock tracks thread ownership.

Remarks

SpinLock is a non-reentrant lock, meaning that if a thread holds the lock, it is not allowed to enter the lock again. If thread ownership tracking is enabled (whether it's enabled is available through IsThreadOwnerTrackingEnabled), an exception will be thrown when a thread tries to re-enter a lock it already holds. However, if thread ownership tracking is disabled, attempting to enter a lock already held will result in deadlock.

Exceptions

Exception | Condition
System.Threading..::.LockRecursionException | Thread ownership tracking is enabled, and the current thread has already acquired this lock.
System..::.ArgumentException | The lockTaken argument must be initialized to false prior to calling Enter.

See Also

SpinLock Structure
System.Threading Namespace


Exit Method

[image] [image]

.NET Framework Class Library
SpinLock..::.Exit Method
SpinLock Structure See Also Send Feedback

Overload List

Name | Description
Exit()()() | Releases the lock.
Exit(Boolean) | Releases the lock.

See Also

SpinLock Structure
System.Threading Namespace


Exit Method

[image]

.NET Framework Class Library
SpinLock..::.Exit Method
SpinLock Structure See Also Send Feedback

Releases the lock.

Namespace: System.Threading
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Sub Exit
C#
public void Exit()

Remarks

The default overload of Exit()()() provides the same behavior as if calling Exit(Boolean) using true as the argument.

Exceptions

Exception | Condition
System.Threading..::.SynchronizationLockException | Thread ownership tracking is enabled, and the current thread is not the owner of this lock.

See Also

SpinLock Structure
Exit Overload
System.Threading Namespace


Exit Method (Boolean)

[image]

.NET Framework Class Library
SpinLock..::.Exit Method (Boolean)
SpinLock Structure See Also Send Feedback

Releases the lock.

Namespace: System.Threading
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Sub Exit ( _
    useMemoryBarrier As Boolean _
)
C#
public void Exit(
    bool useMemoryBarrier
)

Parameters

useMemoryBarrier
Type: System..::.Boolean
A Boolean value that indicates whether a memory fence should be issued in order to immediately publish the exit operation to other threads.

Remarks

Calling Exit(Boolean) with the useMemoryBarrier argument set to true will improve the fairness of the lock at the expense of some performance. The default Enter(Boolean%) overload behaves as if specifying true for useMemoryBarrier.

Exceptions

Exception | Condition
System.Threading..::.SynchronizationLockException | Thread ownership tracking is enabled, and the current thread is not the owner of this lock.

See Also

SpinLock Structure
Exit Overload
System.Threading Namespace


TryEnter Method

[image] [image]

.NET Framework Class Library
SpinLock..::.TryEnter Method
SpinLock Structure See Also Send Feedback

Overload List

Name | Description
TryEnter(Boolean%) | Attempts to acquire the lock in a reliable manner, such that even if an exception occurs within the method call, lockTaken can be examined reliably to determine whether the lock was acquired.
TryEnter(Int32, Boolean%) | Attempts to acquire the lock in a reliable manner, such that even if an exception occurs within the method call, lockTaken can be examined reliably to determine whether the lock was acquired.
TryEnter(TimeSpan, Boolean%) | Attempts to acquire the lock in a reliable manner, such that even if an exception occurs within the method call, lockTaken can be examined reliably to determine whether the lock was acquired.

See Also

SpinLock Structure
System.Threading Namespace


TryEnter Method (Boolean)

[image]

.NET Framework Class Library
SpinLock..::.TryEnter Method (Boolean%)
SpinLock Structure See Also Send Feedback

Attempts to acquire the lock in a reliable manner, such that even if an exception occurs within the method call, lockTaken can be examined reliably to determine whether the lock was acquired.

Namespace: System.Threading
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Sub TryEnter ( _
    ByRef lockTaken As Boolean _
)
C#
public void TryEnter(
    ref bool lockTaken
)

Parameters

lockTaken
Type: System..::.Boolean %
True if the lock is acquired; otherwise, false. lockTaken must be initialized to false prior to calling this method.

Remarks

Unlike Enter(Boolean%), TryEnter will not block waiting for the lock to be available. If the lock is not available when TryEnter is called, it will return immediately without any further spinning.

Exceptions

Exception | Condition
System.Threading..::.LockRecursionException | Thread ownership tracking is enabled, and the current thread has already acquired this lock.
System..::.ArgumentException | The lockTaken argument must be initialized to false prior to calling TryEnter.

See Also

SpinLock Structure
TryEnter Overload
System.Threading Namespace


TryEnter Method (Int32, Boolean)

[image]

.NET Framework Class Library
SpinLock..::.TryEnter Method (Int32, Boolean%)
SpinLock Structure See Also Send Feedback

Attempts to acquire the lock in a reliable manner, such that even if an exception occurs within the method call, lockTaken can be examined reliably to determine whether the lock was acquired.

Namespace: System.Threading
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Sub TryEnter ( _
    millisecondsTimeout As Integer, _
    ByRef lockTaken As Boolean _
)
C#
public void TryEnter(
    int millisecondsTimeout,
    ref bool lockTaken
)

Parameters

millisecondsTimeout
Type: System..::.Int32
The number of milliseconds to wait, or Infinite (-1) to wait indefinitely.
lockTaken
Type: System..::.Boolean %
True if the lock is acquired; otherwise, false. lockTaken must be initialized to false prior to calling this method.

Remarks

Unlike Enter(Boolean%), TryEnter will not block indefinitely waiting for the lock to be available. It will block until either the lock is available or until the millisecondsTimeout has expired.

Exceptions

Exception | Condition
System.Threading..::.LockRecursionException | Thread ownership tracking is enabled, and the current thread has already acquired this lock.
System..::.ArgumentException | The lockTaken argument must be initialized to false prior to calling TryEnter.
System..::.ArgumentOutOfRangeException | millisecondsTimeout is a negative number other than -1, which represents an infinite time-out.

See Also

SpinLock Structure
TryEnter Overload
System.Threading Namespace


TryEnter Method (TimeSpan, Boolean)

[image]

.NET Framework Class Library
SpinLock..::.TryEnter Method (TimeSpan, Boolean%)
SpinLock Structure See Also Send Feedback

Attempts to acquire the lock in a reliable manner, such that even if an exception occurs within the method call, lockTaken can be examined reliably to determine whether the lock was acquired.

Namespace: System.Threading
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Sub TryEnter ( _
    timeout As TimeSpan, _
    ByRef lockTaken As Boolean _
)
C#
public void TryEnter(
    TimeSpan timeout,
    ref bool lockTaken
)

Parameters

timeout
Type: System..::.TimeSpan
A TimeSpan that represents the number of milliseconds to wait, or a TimeSpan that represents -1 milliseconds to wait indefinitely.
lockTaken
Type: System..::.Boolean %
True if the lock is acquired; otherwise, false. lockTaken must be initialized to false prior to calling this method.

Remarks

Unlike Enter(Boolean%), TryEnter will not block indefinitely waiting for the lock to be available. It will block until either the lock is available or until the timeout has expired.

Exceptions

Exception | Condition
System.Threading..::.LockRecursionException | Thread ownership tracking is enabled, and the current thread has already acquired this lock.
System..::.ArgumentException | The lockTaken argument must be initialized to false prior to calling TryEnter.
System..::.ArgumentOutOfRangeException | timeout is a negative number other than -1 milliseconds, which represents an infinite time-out -or- timeout is greater than MaxValue milliseconds.

See Also

SpinLock Structure
TryEnter Overload
System.Threading Namespace


SpinLock Properties

[image] [image]

.NET Framework Class Library
SpinLock Properties
SpinLock Structure See Also Send Feedback

The SpinLock type exposes the following members.

Properties

Name | Description
IsHeld | Gets whether the lock is currently held by any thread.
IsHeldByCurrentThread | Gets whether the lock is currently held by any thread.
IsThreadOwnerTrackingEnabled | Gets whether thread ownership tracking is enabled for this instance.

See Also

SpinLock Structure
System.Threading Namespace


IsHeld Property

[image]

.NET Framework Class Library
SpinLock..::.IsHeld Property
SpinLock Structure See Also Send Feedback

Gets whether the lock is currently held by any thread.

Namespace: System.Threading
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public ReadOnly Property IsHeld As Boolean
C#
public bool IsHeld { get; }

See Also

SpinLock Structure
System.Threading Namespace


IsHeldByCurrentThread Property

[image]

.NET Framework Class Library
SpinLock..::.IsHeldByCurrentThread Property
SpinLock Structure See Also Send Feedback

Gets whether the lock is currently held by any thread.
Gets whether the lock is held by the current thread.

Namespace: System.Threading
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public ReadOnly Property IsHeldByCurrentThread As Boolean
C#
public bool IsHeldByCurrentThread { get; }

Remarks

If the lock was initialized to track owner threads, this will return whether the lock is acquired by the current thread. It is invalid to use this property when the lock was initialized to not track thread ownership.

Exceptions

Exception | Condition
System..::.InvalidOperationException | Thread ownership tracking is disabled.

See Also

SpinLock Structure
System.Threading Namespace


IsThreadOwnerTrackingEnabled Property

[image]

.NET Framework Class Library
SpinLock..::.IsThreadOwnerTrackingEnabled Property
SpinLock Structure See Also Send Feedback

Gets whether thread ownership tracking is enabled for this instance.

Namespace: System.Threading
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public ReadOnly Property IsThreadOwnerTrackingEnabled As Boolean
C#
public bool IsThreadOwnerTrackingEnabled { get; }

See Also

SpinLock Structure
System.Threading Namespace


SpinWait Structure

[image]

.NET Framework Class Library
SpinWait Structure
See Also Send Feedback

Provides support for spin-based waiting.

Namespace: System.Threading
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
<HostProtectionAttribute(SecurityAction.LinkDemand, Synchronization := True,  _
    ExternalThreading := True)> _
Public Structure SpinWait
C#
[HostProtectionAttribute(SecurityAction.LinkDemand, Synchronization = true,
    ExternalThreading = true)]
public struct SpinWait

Remarks

SpinWait encapsulates common spinning logic. On single-processor machines, yields are always used instead of busy waits, and on computers with Intel™ processors employing Hyper-Threading™ technology, it helps to prevent hardware thread starvation. SpinWait encapsulates a good mixture of spinning and true yielding.

SpinWait is a value type, which means that low-level code can utilize SpinWait without fear of unnecessary allocation overheads. SpinWait is not generally useful for ordinary applications. In most cases, you should use the synchronization classes provided by the .NET Framework, such as Monitor. For most purposes where spin waiting is required, however, the SpinWait type should be preferred over the SpinWait(Int32) method.

While SpinWait is designed to be used in concurrent applications, it is not designed to be used from multiple threads concurrently. SpinWait's members are not thread-safe. If multiple threads must spin, each should use its own instance of SpinWait.

See Also

System.Threading Namespace


SpinWait Methods

[image] [image]

.NET Framework Class Library
SpinWait Methods
SpinWait Structure See Also Send Feedback

The SpinWait type exposes the following members.

Methods

Name | Description
Equals | (Inherited from ValueType.)
Finalize | (Inherited from Object.)
GetHashCode | (Inherited from ValueType.)
GetType | (Inherited from Object.)
MemberwiseClone | (Inherited from Object.)
Reset | Resets the spin counter.
SpinOnce | Performs a single spin.
SpinUntil | Overloaded.
ToString | (Inherited from ValueType.)

See Also

SpinWait Structure
System.Threading Namespace


Reset Method

[image]

.NET Framework Class Library
SpinWait..::.Reset Method
SpinWait Structure See Also Send Feedback

Resets the spin counter.

Namespace: System.Threading
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Sub Reset
C#
public void Reset()

Remarks

This makes SpinOnce()()() and NextSpinWillYield behave as though no calls to SpinOnce()()() had been issued on this instance. If a SpinWait instance is reused many times, it may be useful to reset it to avoid yielding too soon.

See Also

SpinWait Structure
System.Threading Namespace


SpinOnce Method

[image]

.NET Framework Class Library
SpinWait..::.SpinOnce Method
SpinWait Structure See Also Send Feedback

Performs a single spin.

Namespace: System.Threading
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Sub SpinOnce
C#
public void SpinOnce()

Remarks

This is typically called in a loop, and may change in behavior based on the number of times a SpinOnce()()() has been called thus far on this instance.

See Also

SpinWait Structure
System.Threading Namespace


SpinUntil Method

[image] [image]

.NET Framework Class Library
SpinWait..::.SpinUntil Method
SpinWait Structure See Also Send Feedback

Overload List

Name | Description
SpinUntil(Func<(Of <(Boolean>)>)) | Spins until the specified condition is satisfied.
SpinUntil(Func<(Of <(Boolean>)>), Int32) | Spins until the specified condition is satisfied or until the specified timeout is expired.
SpinUntil(Func<(Of <(Boolean>)>), TimeSpan) | Spins until the specified condition is satisfied or until the specified timeout is expired.

See Also

SpinWait Structure
System.Threading Namespace


SpinUntil Method (Func(Boolean))

[image]

.NET Framework Class Library
SpinWait..::.SpinUntil Method (Func<(Of <(Boolean>)>))
SpinWait Structure See Also Send Feedback

Spins until the specified condition is satisfied.

Namespace: System.Threading
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Sub SpinUntil ( _
    condition As Func(Of Boolean) _
)
C#
public static void SpinUntil(
    Func<bool> condition
)

Parameters

condition
Type: System..::.Func<(Of <(Boolean>)>)
A delegate to be executed over and over until it returns true.

Exceptions

Exception | Condition
System..::.ArgumentNullException | The condition argument is null.

See Also

SpinWait Structure
SpinUntil Overload
System.Threading Namespace


SpinUntil Method (Func(Boolean), Int32)

[image]

.NET Framework Class Library
SpinWait..::.SpinUntil Method (Func<(Of <(Boolean>)>), Int32)
SpinWait Structure See Also Send Feedback

Spins until the specified condition is satisfied or until the specified timeout is expired.

Namespace: System.Threading
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function SpinUntil ( _
    condition As Func(Of Boolean), _
    millisecondsTimeout As Integer _
) As Boolean
C#
public static bool SpinUntil(
    Func<bool> condition,
    int millisecondsTimeout
)

Parameters

condition
Type: System..::.Func<(Of <(Boolean>)>)
A delegate to be executed over and over until it returns true.
millisecondsTimeout
Type: System..::.Int32
The number of milliseconds to wait, or Infinite (-1) to wait indefinitely.

Return Value

True if the condition is satisfied within the timeout; otherwise, false

Exceptions

Exception | Condition
System..::.ArgumentNullException | The condition argument is null.
System..::.ArgumentOutOfRangeException | millisecondsTimeout is a negative number other than -1, which represents an infinite time-out.

See Also

SpinWait Structure
SpinUntil Overload
System.Threading Namespace


SpinUntil Method (Func(Boolean), TimeSpan)

[image]

.NET Framework Class Library
SpinWait..::.SpinUntil Method (Func<(Of <(Boolean>)>), TimeSpan)
SpinWait Structure See Also Send Feedback

Spins until the specified condition is satisfied or until the specified timeout is expired.

Namespace: System.Threading
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function SpinUntil ( _
    condition As Func(Of Boolean), _
    timeout As TimeSpan _
) As Boolean
C#
public static bool SpinUntil(
    Func<bool> condition,
    TimeSpan timeout
)

Parameters

condition
Type: System..::.Func<(Of <(Boolean>)>)
A delegate to be executed over and over until it returns true.
timeout
Type: System..::.TimeSpan
A TimeSpan that represents the number of milliseconds to wait, or a TimeSpan that represents -1 milliseconds to wait indefinitely.

Return Value

True if the condition is satisfied within the timeout; otherwise, false

Exceptions

Exception | Condition
System..::.ArgumentNullException | The condition argument is null.
System..::.ArgumentOutOfRangeException | timeout is a negative number other than -1 milliseconds, which represents an infinite time-out -or- timeout is greater than MaxValue.

See Also

SpinWait Structure
SpinUntil Overload
System.Threading Namespace


SpinWait Properties

[image] [image]

.NET Framework Class Library
SpinWait Properties
SpinWait Structure See Also Send Feedback

The SpinWait type exposes the following members.

Properties

Name | Description
Count | Gets the number of times SpinOnce()()() has been called on this instance.
NextSpinWillYield | Gets whether the next call to SpinOnce()()() will yield the processor, triggering a forced context switch.

See Also

SpinWait Structure
System.Threading Namespace


Count Property

[image]

.NET Framework Class Library
SpinWait..::.Count Property
SpinWait Structure See Also Send Feedback

Gets the number of times SpinOnce()()() has been called on this instance.

Namespace: System.Threading
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public ReadOnly Property Count As Integer
C#
public int Count { get; }

See Also

SpinWait Structure
System.Threading Namespace


NextSpinWillYield Property

[image]

.NET Framework Class Library
SpinWait..::.NextSpinWillYield Property
SpinWait Structure See Also Send Feedback

Gets whether the next call to SpinOnce()()() will yield the processor, triggering a forced context switch.

Namespace: System.Threading
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public ReadOnly Property NextSpinWillYield As Boolean
C#
public bool NextSpinWillYield { get; }

Field Value

Whether the next call to SpinOnce()()() will yield the processor, triggering a forced context switch.

Remarks

On a single-CPU machine, SpinOnce()()() always yields the processor. On machines with multiple CPUs, SpinOnce()()() may yield after an unspecified number of calls.

See Also

SpinWait Structure
System.Threading Namespace


ThreadLocal(T) Class

[image]

.NET Framework Class Library
ThreadLocal<(Of <(T>)>) Class
See Also Send Feedback

Provides thread-local storage of data.

Namespace: System.Threading
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
<HostProtectionAttribute(SecurityAction.LinkDemand, Synchronization := True,  _
    ExternalThreading := True)> _
Public Class ThreadLocal(Of T) _
    Implements IDisposable
C#
[HostProtectionAttribute(SecurityAction.LinkDemand, Synchronization = true,
    ExternalThreading = true)]
public class ThreadLocal<T> : IDisposable

Type Parameters

T
Specifies the type of data stored per-thread.

Remarks

With the exception of Dispose()()(), all public and protected members of ThreadLocal<(Of <(T>)>) are thread-safe and may be used concurrently from multiple threads.

Inheritance Hierarchy

System..::.Object
System.Threading..::.ThreadLocal<(Of <(T>)>)

See Also

System.Threading Namespace


ThreadLocal(T) Constructor

[image] [image]

.NET Framework Class Library
ThreadLocal<(Of <(T>)>) Constructor
ThreadLocal<(Of <(T>)>) Class See Also Send Feedback

Overload List

Name | Description
ThreadLocal<(Of <(T>)>)()()() | Initializes the ThreadLocal<(Of <(T>)>) instance.
ThreadLocal<(Of <(T>)>)(Func<(Of <(T>)>)) | Initializes the ThreadLocal<(Of <(T>)>) instance with the specified valueFactory function.

See Also

ThreadLocal<(Of <(T>)>) Class
System.Threading Namespace


ThreadLocal(T) Constructor

[image]

.NET Framework Class Library
ThreadLocal<(Of <(T>)>) Constructor
ThreadLocal<(Of <(T>)>) Class See Also Send Feedback

Initializes the ThreadLocal<(Of <(T>)>) instance.

Namespace: System.Threading
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Sub New
C#
public ThreadLocal()

See Also

ThreadLocal<(Of <(T>)>) Class
ThreadLocal<(Of <(T>)>) Overload
System.Threading Namespace


ThreadLocal(T) Constructor (Func(T))

[image]

.NET Framework Class Library
ThreadLocal<(Of <(T>)>) Constructor (Func<(Of <(T>)>))
ThreadLocal<(Of <(T>)>) Class See Also Send Feedback

Initializes the ThreadLocal<(Of <(T>)>) instance with the specified valueFactory function.

Namespace: System.Threading
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Sub New ( _
    valueFactory As Func(Of T) _
)
C#
public ThreadLocal(
    Func<T> valueFactory
)

Parameters

valueFactory
Type: System..::.Func<(Of <( T >)>)
The Func<(Of <(T>)>) invoked to produce a lazily-initialized value when an attempt is made to retrieve Value without it having been previously initialized.

Exceptions

Exception | Condition
System..::.ArgumentNullException | valueFactory is a null reference (Nothing in Visual Basic).

See Also

ThreadLocal<(Of <(T>)>) Class
ThreadLocal<(Of <(T>)>) Overload
System.Threading Namespace


ThreadLocal(T) Methods

[image] [image]

.NET Framework Class Library
ThreadLocal<(Of <(T>)>) Methods
ThreadLocal<(Of <(T>)>) Class See Also Send Feedback

The ThreadLocal<(Of <(T>)>) type exposes the following members.

Methods

Name | Description
Dispose | Overloaded.
Equals | (Inherited from Object.)
Finalize | Releases the resources used by this ThreadLocal<(Of <(T>)>) instance. (Overrides Object..::.Finalize()()().)
GetHashCode | (Inherited from Object.)
GetType | (Inherited from Object.)
MemberwiseClone | (Inherited from Object.)
ToString | Creates and returns a string representation of this instance for the current thread. (Overrides Object..::.ToString()()().)

See Also

ThreadLocal<(Of <(T>)>) Class
System.Threading Namespace


Dispose Method

[image] [image]

.NET Framework Class Library
ThreadLocal<(Of <(T>)>)..::.Dispose Method
ThreadLocal<(Of <(T>)>) Class See Also Send Feedback

Overload List

Name | Description
Dispose()()() | Releases the resources used by this ThreadLocal<(Of <(T>)>) instance.
Dispose(Boolean) | Releases the resources used by this ThreadLocal<(Of <(T>)>) instance.

See Also

ThreadLocal<(Of <(T>)>) Class
System.Threading Namespace


Dispose Method

[image]

.NET Framework Class Library
ThreadLocal<(Of <(T>)>)..::.Dispose Method
ThreadLocal<(Of <(T>)>) Class See Also Send Feedback

Releases the resources used by this ThreadLocal<(Of <(T>)>) instance.

Namespace: System.Threading
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Sub Dispose
C#
public void Dispose()

Implements

IDisposable..::.Dispose()()()

Remarks

Unlike most of the members of ThreadLocal<(Of <(T>)>), this method is not thread-safe.

See Also

ThreadLocal<(Of <(T>)>) Class
Dispose Overload
System.Threading Namespace


Dispose Method (Boolean)

[image]

.NET Framework Class Library
ThreadLocal<(Of <(T>)>)..::.Dispose Method (Boolean)
ThreadLocal<(Of <(T>)>) Class See Also Send Feedback

Releases the resources used by this ThreadLocal<(Of <(T>)>) instance.

Namespace: System.Threading
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Protected Overridable Sub Dispose ( _
    disposing As Boolean _
)
C#
protected virtual void Dispose(
    bool disposing
)

Parameters

disposing
Type: System..::.Boolean
A Boolean value that indicates whether this method is being called due to a call to Dispose()()().

Remarks

Unlike most of the members of ThreadLocal<(Of <(T>)>), this method is not thread-safe.

See Also

ThreadLocal<(Of <(T>)>) Class
Dispose Overload
System.Threading Namespace


Finalize Method

[image]

.NET Framework Class Library
ThreadLocal<(Of <(T>)>)..::.Finalize Method
ThreadLocal<(Of <(T>)>) Class See Also Send Feedback

Releases the resources used by this ThreadLocal<(Of <(T>)>) instance.

Namespace: System.Threading
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Protected Overrides Sub Finalize
C#
protected override void Finalize()

See Also

ThreadLocal<(Of <(T>)>) Class
System.Threading Namespace


ToString Method

[image]

.NET Framework Class Library
ThreadLocal<(Of <(T>)>)..::.ToString Method
ThreadLocal<(Of <(T>)>) Class See Also Send Feedback

Creates and returns a string representation of this instance for the current thread.

Namespace: System.Threading
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Overrides Function ToString As String
C#
public override string ToString()

Return Value

The result of calling ToString()()() on the Value.

Remarks

Calling this method forces initialization for the current thread, as is the case with accessing Value directly.

Exceptions

Exception | Condition
System..::.NullReferenceException | The Value for the current thread is a null reference (Nothing in Visual Basic).
System..::.InvalidOperationException | The initialization function referenced Value in an improper manner.
System..::.ObjectDisposedException | The ThreadLocal<(Of <(T>)>) instance has been disposed.

See Also

ThreadLocal<(Of <(T>)>) Class
System.Threading Namespace


ThreadLocal(T) Properties

[image] [image]

.NET Framework Class Library
ThreadLocal<(Of <(T>)>) Properties
ThreadLocal<(Of <(T>)>) Class See Also Send Feedback

The ThreadLocal<(Of <(T>)>) type exposes the following members.

Properties

Name | Description
IsValueCreated | Gets whether Value is initialized on the current thread.
Value | Gets or sets the value of this instance for the current thread.

See Also

ThreadLocal<(Of <(T>)>) Class
System.Threading Namespace


IsValueCreated Property

[image]

.NET Framework Class Library
ThreadLocal<(Of <(T>)>)..::.IsValueCreated Property
ThreadLocal<(Of <(T>)>) Class See Also Send Feedback

Gets whether Value is initialized on the current thread.

Namespace: System.Threading
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public ReadOnly Property IsValueCreated As Boolean
C#
public bool IsValueCreated { get; }

Exceptions

Exception | Condition
System..::.ObjectDisposedException | The ThreadLocal<(Of <(T>)>) instance has been disposed.

See Also

ThreadLocal<(Of <(T>)>) Class
System.Threading Namespace


Value Property

[image]

.NET Framework Class Library
ThreadLocal<(Of <(T>)>)..::.Value Property
ThreadLocal<(Of <(T>)>) Class See Also Send Feedback

Gets or sets the value of this instance for the current thread.

Namespace: System.Threading
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Property Value As T
C#
public T Value { get; set; }

Remarks

If this instance was not previously initialized for the current thread, accessing Value will attempt to initialize it. If an initialization function was supplied during the construction, that initialization will happen by invoking the function to retrieve the initial value for Value. Otherwise, the default value of T will be used.

Exceptions

Exception | Condition
System..::.InvalidOperationException | The initialization function referenced Value in an improper manner.
System..::.ObjectDisposedException | The ThreadLocal<(Of <(T>)>) instance has been disposed.

See Also

ThreadLocal<(Of <(T>)>) Class
System.Threading Namespace


System.Threading.Tasks Namespace

[image]

.NET Framework Class Library
System.Threading.Tasks Namespace
Send Feedback

Classes

Class | Description
Parallel | Provides support for parallel loops and regions.
ParallelLoopState | Enables iterations of Parallel loops to interact with other iterations.
ParallelOptions | Stores options that configure the operation of methods on the Parallel class.
Task | Represents an asynchronous operation.
Task<(Of <(TResult>)>) | Represents an asynchronous operation that produces a result at some time in the future.
TaskCanceledException | Represents an exception used to communicate task cancellation.
TaskCompletionSource<(Of <(TResult>)>) | Represents the producer side of a Task<(Of <(TResult>)>) unbound to a delegate, providing access to the consumer side through the Task property.
TaskExtensions | Provides a set of static (Shared in Visual Basic) methods for working with specific kinds of Task instances.
TaskFactory | Provides support for creating and scheduling Tasks.
TaskFactory<(Of <(TResult>)>) | Provides support for creating and scheduling Task{TResult} objects.
TaskScheduler | Represents an abstract scheduler for tasks.
TaskSchedulerException | Represents an exception used to communicate an invalid operation by a TaskScheduler.
UnobservedTaskExceptionEventArgs | Provides data for the event that is raised when a faulted Task's exception goes unobserved.

Structures

Structure | Description
ParallelLoopResult | Provides completion status on the execution of a Parallel loop.

Enumerations

Enumeration | Description
TaskContinuationOptions | Specifies flags that control optional behavior for the creation and execution of continuation tasks.
TaskCreationOptions | Specifies flags that control optional behavior for the creation and execution of tasks.
TaskStatus | Represents the current stage in the lifecycle of a Task.


Parallel Class

[image]

.NET Framework Class Library
Parallel Class
See Also Send Feedback

Provides support for parallel loops and regions.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
<HostProtectionAttribute(SecurityAction.LinkDemand, Synchronization := True,  _
    ExternalThreading := True)> _
Public NotInheritable Class Parallel
C#
[HostProtectionAttribute(SecurityAction.LinkDemand, Synchronization = true,
    ExternalThreading = true)]
public static class Parallel

Remarks

The Parallel class provides library-based data parallel replacements for common operations such as for loops, for each loops, and execution of a set of statements.

Inheritance Hierarchy

System..::.Object
System.Threading.Tasks..::.Parallel

See Also

System.Threading.Tasks Namespace


Parallel Methods

[image] [image]

.NET Framework Class Library
Parallel Methods
Parallel Class See Also Send Feedback

Methods

Name | Description
For | Overloaded.
ForEach | Overloaded.
Invoke | Overloaded.

See Also

Parallel Class
System.Threading.Tasks Namespace


For Method

[image] [image]

.NET Framework Class Library
Parallel..::.For Method
Parallel Class See Also Send Feedback

Overload List

Name | Description
For(Int32, Int32, Action<(Of <(Int32>)>)) | Executes a for loop in which iterations may run in parallel.
For(Int32, Int32, Action<(Of <(Int32, ParallelLoopState>)>)) | Executes a for loop in which iterations may run in parallel.
For(Int64, Int64, Action<(Of <(Int64>)>)) | Executes a for loop in which iterations may run in parallel.
For(Int64, Int64, Action<(Of <(Int64, ParallelLoopState>)>)) | Executes a for loop in which iterations may run in parallel.
For(Int32, Int32, ParallelOptions, Action<(Of <(Int32>)>)) | Executes a for loop in which iterations may run in parallel.
For(Int32, Int32, ParallelOptions, Action<(Of <(Int32, ParallelLoopState>)>)) | Executes a for loop in which iterations may run in parallel.
For(Int64, Int64, ParallelOptions, Action<(Of <(Int64>)>)) | Executes a for loop in which iterations may run in parallel.
For(Int64, Int64, ParallelOptions, Action<(Of <(Int64, ParallelLoopState>)>)) | Executes a for loop in which iterations may run in parallel.
For<(Of <(TLocal>)>)(Int32, Int32, Func<(Of <(TLocal>)>), Func<(Of <(Int32, ParallelLoopState, TLocal, TLocal>)>), Action<(Of <(TLocal>)>)) | Executes a for loop in which iterations may run in parallel.
For<(Of <(TLocal>)>)(Int64, Int64, Func<(Of <(TLocal>)>), Func<(Of <(Int64, ParallelLoopState, TLocal, TLocal>)>), Action<(Of <(TLocal>)>)) | Executes a for loop in which iterations may run in parallel. Supports 64-bit indices.
For<(Of <(TLocal>)>)(Int32, Int32, ParallelOptions, Func<(Of <(TLocal>)>), Func<(Of <(Int32, ParallelLoopState, TLocal, TLocal>)>), Action<(Of <(TLocal>)>)) | Executes a for loop in which iterations may run in parallel.
For<(Of <(TLocal>)>)(Int64, Int64, ParallelOptions, Func<(Of <(TLocal>)>), Func<(Of <(Int64, ParallelLoopState, TLocal, TLocal>)>), Action<(Of <(TLocal>)>)) | Executes a for loop in which iterations may run in parallel.

See Also

Parallel Class
System.Threading.Tasks Namespace


For Method (Int32, Int32, Action(Int32))

[image]

.NET Framework Class Library
Parallel..::.For Method (Int32, Int32, Action<(Of <(Int32>)>))
Parallel Class See Also Send Feedback

Executes a for loop in which iterations may run in parallel.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function For ( _
    fromInclusive As Integer, _
    toExclusive As Integer, _
    body As Action(Of Integer) _
) As ParallelLoopResult
C#
public static ParallelLoopResult For(
    int fromInclusive,
    int toExclusive,
    Action<int> body
)

Parameters

fromInclusive
Type: System..::.Int32
The start index, inclusive.
toExclusive
Type: System..::.Int32
The end index, exclusive.
body
Type: System..::.Action<(Of <(Int32>)>)
The delegate that is invoked once per iteration.

Return Value

A ParallelLoopResult structure that contains information on what portion of the loop completed.

Remarks

The body delegate is invoked once for each value in the iteration range: [fromInclusive, toExclusive). It is provided with the iteration count (an Int32) as a parameter.

Exceptions

Exception | Condition
System..::.ArgumentNullException | The exception that is thrown when the body argument is null.
System..::.AggregateException | The exception that is thrown to contain an exception thrown from one of the specified delegates.

See Also

Parallel Class
For Overload
System.Threading.Tasks Namespace


For Method (Int32, Int32, Action(Int32, ParallelLoopState))

[image]

.NET Framework Class Library
Parallel..::.For Method (Int32, Int32, Action<(Of <(Int32, ParallelLoopState>)>))
Parallel Class See Also Send Feedback

Executes a for loop in which iterations may run in parallel.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function For ( _
    fromInclusive As Integer, _
    toExclusive As Integer, _
    body As Action(Of Integer, ParallelLoopState) _
) As ParallelLoopResult
C#
public static ParallelLoopResult For(
    int fromInclusive,
    int toExclusive,
    Action<int, ParallelLoopState> body
)

Parameters

fromInclusive
Type: System..::.Int32
The start index, inclusive.
toExclusive
Type: System..::.Int32
The end index, exclusive.
body
Type: System..::.Action<(Of <(Int32, ParallelLoopState >)>)
The delegate that is invoked once per iteration.

Return Value

A ParallelLoopResult structure that contains information on what portion of the loop completed.

Remarks

The body delegate is invoked once for each value in the iteration range: [fromInclusive, toExclusive). It is provided with the following parameters: the iteration count (an Int32), and a ParallelLoopState instance that may be used to break out of the loop prematurely.

Calling ParallelLoopState.Break() informs the For operation that iterations after the current one need not execute. However, all iterations before the current one will still need to be executed if they have not already. Therefore, calling Break is similar to using a break operation within a conventional for loop in a language like C#, but it is not a perfect substitute: for example, there is no guarantee that iterations after the current one will definitely not execute.

If executing all iterations before the current one is not necessary, ParallelLoopState.Stop() should be preferred to using Break. Calling Stop informs the For loop that it may abandon all remaining iterations, regardless of whether they're for interations above or below the current, since all required work has already been completed. As with Break, however, there are no guarantees regarding which other iterations will not execute.

When a loop is ended prematurely, the ParallelLoopState that's returned will contain relevant information about the loop's completion.

Exceptions

Exception | Condition
System..::.ArgumentNullException | The exception that is thrown when the body argument is null.
System..::.AggregateException | The exception that is thrown to contain an exception thrown from one of the specified delegates.

See Also

Parallel Class
For Overload
System.Threading.Tasks Namespace


For Method (Int64, Int64, Action(Int64))

[image]

.NET Framework Class Library
Parallel..::.For Method (Int64, Int64, Action<(Of <(Int64>)>))
Parallel Class See Also Send Feedback

Executes a for loop in which iterations may run in parallel.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function For ( _
    fromInclusive As Long, _
    toExclusive As Long, _
    body As Action(Of Long) _
) As ParallelLoopResult
C#
public static ParallelLoopResult For(
    long fromInclusive,
    long toExclusive,
    Action<long> body
)

Parameters

fromInclusive
Type: System..::.Int64
The start index, inclusive.
toExclusive
Type: System..::.Int64
The end index, exclusive.
body
Type: System..::.Action<(Of <(Int64>)>)
The delegate that is invoked once per iteration.

Return Value

A ParallelLoopResult structure that contains information on what portion of the loop completed.

Remarks

The body delegate is invoked once for each value in the iteration range: [fromInclusive, toExclusive). It is provided with the iteration count (an Int64) as a parameter.

Exceptions

Exception | Condition
System..::.ArgumentNullException | The exception that is thrown when the body argument is null.
System..::.AggregateException | The exception that is thrown to contain an exception thrown from one of the specified delegates.

See Also

Parallel Class
For Overload
System.Threading.Tasks Namespace


For Method (Int64, Int64, Action(Int64, ParallelLoopState))

[image]

.NET Framework Class Library
Parallel..::.For Method (Int64, Int64, Action<(Of <(Int64, ParallelLoopState>)>))
Parallel Class See Also Send Feedback

Executes a for loop in which iterations may run in parallel.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function For ( _
    fromInclusive As Long, _
    toExclusive As Long, _
    body As Action(Of Long, ParallelLoopState) _
) As ParallelLoopResult
C#
public static ParallelLoopResult For(
    long fromInclusive,
    long toExclusive,
    Action<long, ParallelLoopState> body
)

Parameters

fromInclusive
Type: System..::.Int64
The start index, inclusive.
toExclusive
Type: System..::.Int64
The end index, exclusive.
body
Type: System..::.Action<(Of <(Int64, ParallelLoopState >)>)
The delegate that is invoked once per iteration.

Return Value

A ParallelLoopResult structure that contains information on what portion of the loop completed.

Remarks

The body delegate is invoked once for each value in the iteration range: [fromInclusive, toExclusive). It is provided with the following parameters: the iteration count (an Int64), and a ParallelLoopState instance that may be used to break out of the loop prematurely.

Exceptions

Exception | Condition
System..::.ArgumentNullException | The exception that is thrown when the body argument is null.
System..::.AggregateException | The exception that is thrown to contain an exception thrown from one of the specified delegates.

See Also

Parallel Class
For Overload
System.Threading.Tasks Namespace


For Method (Int32, Int32, ParallelOptions, Action(Int32))

[image]

.NET Framework Class Library
Parallel..::.For Method (Int32, Int32, ParallelOptions, Action<(Of <(Int32>)>))
Parallel Class See Also Send Feedback

Executes a for loop in which iterations may run in parallel.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function For ( _
    fromInclusive As Integer, _
    toExclusive As Integer, _
    parallelOptions As ParallelOptions, _
    body As Action(Of Integer) _
) As ParallelLoopResult
C#
public static ParallelLoopResult For(
    int fromInclusive,
    int toExclusive,
    ParallelOptions parallelOptions,
    Action<int> body
)

Parameters

fromInclusive
Type: System..::.Int32
The start index, inclusive.
toExclusive
Type: System..::.Int32
The end index, exclusive.
parallelOptions
Type: System.Threading.Tasks..::.ParallelOptions
A ParallelOptions instance that configures the behavior of this operation.
body
Type: System..::.Action<(Of <(Int32>)>)
The delegate that is invoked once per iteration.

Return Value

A ParallelLoopResult structure that contains information on what portion of the loop completed.

Remarks

The body delegate is invoked once for each value in the iteration range: [fromInclusive, toExclusive). It is provided with the iteration count (an Int32) as a parameter.

Exceptions

Exception | Condition
System..::.ArgumentNullException | The exception that is thrown when the body argument is null.
System..::.ArgumentNullException | The exception that is thrown when the parallelOptions argument is null.
System..::.OperationCanceledException | The exception that is thrown when the CancellationToken in the parallelOptions argument is set.
System..::.AggregateException | The exception that is thrown to contain an exception thrown from one of the specified delegates.
System..::.ObjectDisposedException | The exception that is thrown when the the CancellationTokenSource associated with the the CancellationToken in the parallelOptions has been disposed.

See Also

Parallel Class
For Overload
System.Threading.Tasks Namespace


For Method (Int32, Int32, ParallelOptions, Action(Int32, ParallelLoopState))

[image]

.NET Framework Class Library
Parallel..::.For Method (Int32, Int32, ParallelOptions, Action<(Of <(Int32, ParallelLoopState>)>))
Parallel Class See Also Send Feedback

Executes a for loop in which iterations may run in parallel.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function For ( _
    fromInclusive As Integer, _
    toExclusive As Integer, _
    parallelOptions As ParallelOptions, _
    body As Action(Of Integer, ParallelLoopState) _
) As ParallelLoopResult
C#
public static ParallelLoopResult For(
    int fromInclusive,
    int toExclusive,
    ParallelOptions parallelOptions,
    Action<int, ParallelLoopState> body
)

Parameters

fromInclusive
Type: System..::.Int32
The start index, inclusive.
toExclusive
Type: System..::.Int32
The end index, exclusive.
parallelOptions
Type: System.Threading.Tasks..::.ParallelOptions
A ParallelOptions instance that configures the behavior of this operation.
body
Type: System..::.Action<(Of <(Int32, ParallelLoopState >)>)
The delegate that is invoked once per iteration.

Return Value

A ParallelLoopResult structure that contains information on what portion of the loop completed.

Remarks

The body delegate is invoked once for each value in the iteration range: [fromInclusive, toExclusive). It is provided with the following parameters: the iteration count (an Int32), and a ParallelLoopState instance that may be used to break out of the loop prematurely.

Exceptions

Exception | Condition
System..::.ArgumentNullException | The exception that is thrown when the body argument is null.
System..::.ArgumentNullException | The exception that is thrown when the parallelOptions argument is null.
System..::.OperationCanceledException | The exception that is thrown when the CancellationToken in the parallelOptions argument is set.
System..::.AggregateException | The exception that is thrown to contain an exception thrown from one of the specified delegates.
System..::.ObjectDisposedException | The exception that is thrown when the the CancellationTokenSource associated with the the CancellationToken in the parallelOptions has been disposed.

See Also

Parallel Class
For Overload
System.Threading.Tasks Namespace


For Method (Int64, Int64, ParallelOptions, Action(Int64))

[image]

.NET Framework Class Library
Parallel..::.For Method (Int64, Int64, ParallelOptions, Action<(Of <(Int64>)>))
Parallel Class See Also Send Feedback

Executes a for loop in which iterations may run in parallel.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function For ( _
    fromInclusive As Long, _
    toExclusive As Long, _
    parallelOptions As ParallelOptions, _
    body As Action(Of Long) _
) As ParallelLoopResult
C#
public static ParallelLoopResult For(
    long fromInclusive,
    long toExclusive,
    ParallelOptions parallelOptions,
    Action<long> body
)

Parameters

fromInclusive
Type: System..::.Int64
The start index, inclusive.
toExclusive
Type: System..::.Int64
The end index, exclusive.
parallelOptions
Type: System.Threading.Tasks..::.ParallelOptions
A ParallelOptions instance that configures the behavior of this operation.
body
Type: System..::.Action<(Of <(Int64>)>)
The delegate that is invoked once per iteration.

Return Value

A ParallelLoopResult structure that contains information on what portion of the loop completed.

Remarks

The body delegate is invoked once for each value in the iteration range: [fromInclusive, toExclusive). It is provided with the iteration count (an Int64) as a parameter.

Exceptions

Exception | Condition
System..::.ArgumentNullException | The exception that is thrown when the body argument is null.
System..::.ArgumentNullException | The exception that is thrown when the parallelOptions argument is null.
System..::.OperationCanceledException | The exception that is thrown when the CancellationToken in the parallelOptions argument is set.
System..::.AggregateException | The exception that is thrown to contain an exception thrown from one of the specified delegates.
System..::.ObjectDisposedException | The exception that is thrown when the the CancellationTokenSource associated with the the CancellationToken in the parallelOptions has been disposed.

See Also

Parallel Class
For Overload
System.Threading.Tasks Namespace


For Method (Int64, Int64, ParallelOptions, Action(Int64, ParallelLoopState))

[image]

.NET Framework Class Library
Parallel..::.For Method (Int64, Int64, ParallelOptions, Action<(Of <(Int64, ParallelLoopState>)>))
Parallel Class See Also Send Feedback

Executes a for loop in which iterations may run in parallel.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function For ( _
    fromInclusive As Long, _
    toExclusive As Long, _
    parallelOptions As ParallelOptions, _
    body As Action(Of Long, ParallelLoopState) _
) As ParallelLoopResult
C#
public static ParallelLoopResult For(
    long fromInclusive,
    long toExclusive,
    ParallelOptions parallelOptions,
    Action<long, ParallelLoopState> body
)

Parameters

fromInclusive
Type: System..::.Int64
The start index, inclusive.
toExclusive
Type: System..::.Int64
The end index, exclusive.
parallelOptions
Type: System.Threading.Tasks..::.ParallelOptions
A ParallelOptions instance that configures the behavior of this operation.
body
Type: System..::.Action<(Of <(Int64, ParallelLoopState >)>)
The delegate that is invoked once per iteration.

Return Value

A ParallelLoopResult structure that contains information on what portion of the loop completed.

Remarks

The body delegate is invoked once for each value in the iteration range: [fromInclusive, toExclusive). It is provided with the following parameters: the iteration count (an Int64), and a ParallelLoopState instance that may be used to break out of the loop prematurely.

Exceptions

Exception | Condition
System..::.ArgumentNullException | The exception that is thrown when the body argument is null.
System..::.ArgumentNullException | The exception that is thrown when the parallelOptions argument is null.
System..::.OperationCanceledException | The exception that is thrown when the CancellationToken in the parallelOptions argument is set.
System..::.AggregateException | The exception that is thrown to contain an exception thrown from one of the specified delegates.
System..::.ObjectDisposedException | The exception that is thrown when the the CancellationTokenSource associated with the the CancellationToken in the parallelOptions has been disposed.

See Also

Parallel Class
For Overload
System.Threading.Tasks Namespace


For(TLocal) Method (Int32, Int32, Func(TLocal), Func(Int32, ParallelLoopState, TLocal, TLocal), Action(TLocal))

[image]

.NET Framework Class Library
Parallel..::.For<(Of <(TLocal>)>) Method (Int32, Int32, Func<(Of <(TLocal>)>), Func<(Of <(Int32, ParallelLoopState, TLocal, TLocal>)>), Action<(Of <(TLocal>)>))
Parallel Class See Also Send Feedback

Executes a for loop in which iterations may run in parallel.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function For(Of TLocal) ( _
    fromInclusive As Integer, _
    toExclusive As Integer, _
    localInit As Func(Of TLocal), _
    body As Func(Of Integer, ParallelLoopState, TLocal, TLocal), _
    localFinally As Action(Of TLocal) _
) As ParallelLoopResult
C#
public static ParallelLoopResult For<TLocal>(
    int fromInclusive,
    int toExclusive,
    Func<TLocal> localInit,
    Func<int, ParallelLoopState, TLocal, TLocal> body,
    Action<TLocal> localFinally
)

Parameters

fromInclusive
Type: System..::.Int32
The start index, inclusive.
toExclusive
Type: System..::.Int32
The end index, exclusive.
localInit
Type: System..::.Func<(Of <(TLocal>)>)
The function delegate that returns the initial state of the local data for each thread.
body
Type: System..::.Func<(Of <(Int32, ParallelLoopState, TLocal, TLocal>)>)
The delegate that is invoked once per iteration.
localFinally
Type: System..::.Action<(Of <(TLocal>)>)
The delegate that performs a final action on the local state of each thread.

Type Parameters

TLocal
The type of the thread-local data.

Return Value

A ParallelLoopResult structure that contains information on what portion of the loop completed.

Remarks

The body delegate is invoked once for each value in the iteration range: [fromInclusive, toExclusive). It is provided with the following parameters: the iteration count (an Int32), a ParallelLoopState instance that may be used to break out of the loop prematurely, and some local state that may be shared amongst iterations that execute on the same thread.

The localInit delegate is invoked once for each thread that participates in the loop's execution and returns the initial local state for each of those threads. These initial states are passed to the first body invocations on each thread. Then, every subsequent body invocation returns a possibly modified state value that is passed to the next body invocation. Finally, the last body invocation on each thread returns a state value that is passed to the localFinally delegate. The localFinally delegate is invoked once per thread to perform a final action on each thread's local state.

Exceptions

Exception | Condition
System..::.ArgumentNullException | The exception that is thrown when the body argument is null.
System..::.ArgumentNullException | The exception that is thrown when the localInit argument is null.
System..::.ArgumentNullException | The exception that is thrown when the localFinally argument is null.
System..::.AggregateException | The exception that is thrown to contain an exception thrown from one of the specified delegates.

See Also

Parallel Class
For Overload
System.Threading.Tasks Namespace


For(TLocal) Method (Int64, Int64, Func(TLocal), Func(Int64, ParallelLoopState, TLocal, TLocal), Action(TLocal))

[image]

.NET Framework Class Library
Parallel..::.For<(Of <(TLocal>)>) Method (Int64, Int64, Func<(Of <(TLocal>)>), Func<(Of <(Int64, ParallelLoopState, TLocal, TLocal>)>), Action<(Of <(TLocal>)>))
Parallel Class See Also Send Feedback

Executes a for loop in which iterations may run in parallel. Supports 64-bit indices.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function For(Of TLocal) ( _
    fromInclusive As Long, _
    toExclusive As Long, _
    localInit As Func(Of TLocal), _
    body As Func(Of Long, ParallelLoopState, TLocal, TLocal), _
    localFinally As Action(Of TLocal) _
) As ParallelLoopResult
C#
public static ParallelLoopResult For<TLocal>(
    long fromInclusive,
    long toExclusive,
    Func<TLocal> localInit,
    Func<long, ParallelLoopState, TLocal, TLocal> body,
    Action<TLocal> localFinally
)

Parameters

fromInclusive
Type: System..::.Int64
The start index, inclusive.
toExclusive
Type: System..::.Int64
The end index, exclusive.
localInit
Type: System..::.Func<(Of <(TLocal>)>)
The function delegate that returns the initial state of the local data for each thread.
body
Type: System..::.Func<(Of <(Int64, ParallelLoopState, TLocal, TLocal>)>)
The delegate that is invoked once per iteration.
localFinally
Type: System..::.Action<(Of <(TLocal>)>)
The delegate that performs a final action on the local state of each thread.

Type Parameters

TLocal
The type of the thread-local data.

Return Value

A ParallelLoopResult structure that contains information on what portion of the loop completed.

Remarks

The body delegate is invoked once for each value in the iteration range: [fromInclusive, toExclusive). It is provided with the following parameters: the iteration count (an Int64), a ParallelLoopState instance that may be used to break out of the loop prematurely, and some local state that may be shared amongst iterations that execute on the same thread.

The localInit delegate is invoked once for each thread that participates in the loop's execution and returns the initial local state for each of those threads. These initial states are passed to the first body invocations on each thread. Then, every subsequent body invocation returns a possibly modified state value that is passed to the next body invocation. Finally, the last body invocation on each thread returns a state value that is passed to the localFinally delegate. The localFinally delegate is invoked once per thread to perform a final action on each thread's local state.

Exceptions

Exception | Condition
System..::.ArgumentNullException | The exception that is thrown when the body argument is null.
System..::.ArgumentNullException | The exception that is thrown when the localInit argument is null.
System..::.ArgumentNullException | The exception that is thrown when the localFinally argument is null.
System..::.AggregateException | The exception that is thrown to contain an exception thrown from one of the specified delegates.

See Also

Parallel Class
For Overload
System.Threading.Tasks Namespace


For(TLocal) Method (Int32, Int32, ParallelOptions, Func(TLocal), Func(Int32, ParallelLoopState, TLocal, TLocal), Action(TLocal))

[image]

.NET Framework Class Library
Parallel..::.For<(Of <(TLocal>)>) Method (Int32, Int32, ParallelOptions, Func<(Of <(TLocal>)>), Func<(Of <(Int32, ParallelLoopState, TLocal, TLocal>)>), Action<(Of <(TLocal>)>))
Parallel Class See Also Send Feedback

Executes a for loop in which iterations may run in parallel.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function For(Of TLocal) ( _
    fromInclusive As Integer, _
    toExclusive As Integer, _
    parallelOptions As ParallelOptions, _
    localInit As Func(Of TLocal), _
    body As Func(Of Integer, ParallelLoopState, TLocal, TLocal), _
    localFinally As Action(Of TLocal) _
) As ParallelLoopResult
C#
public static ParallelLoopResult For<TLocal>(
    int fromInclusive,
    int toExclusive,
    ParallelOptions parallelOptions,
    Func<TLocal> localInit,
    Func<int, ParallelLoopState, TLocal, TLocal> body,
    Action<TLocal> localFinally
)

Parameters

fromInclusive
Type: System..::.Int32
The start index, inclusive.
toExclusive
Type: System..::.Int32
The end index, exclusive.
parallelOptions
Type: System.Threading.Tasks..::.ParallelOptions
A ParallelOptions instance that configures the behavior of this operation.
localInit
Type: System..::.Func<(Of <(TLocal>)>)
The function delegate that returns the initial state of the local data for each thread.
body
Type: System..::.Func<(Of <(Int32, ParallelLoopState, TLocal, TLocal>)>)
The delegate that is invoked once per iteration.
localFinally
Type: System..::.Action<(Of <(TLocal>)>)
The delegate that performs a final action on the local state of each thread.

Type Parameters

TLocal
The type of the thread-local data.

Return Value

A ParallelLoopResult structure that contains information on what portion of the loop completed.

Remarks

The body delegate is invoked once for each value in the iteration range: [fromInclusive, toExclusive). It is provided with the following parameters: the iteration count (an Int32), a ParallelLoopState instance that may be used to break out of the loop prematurely, and some local state that may be shared amongst iterations that execute on the same thread.

The localInit delegate is invoked once for each thread that participates in the loop's execution and returns the initial local state for each of those threads. These initial states are passed to the first body invocations on each thread. Then, every subsequent body invocation returns a possibly modified state value that is passed to the next body invocation. Finally, the last body invocation on each thread returns a state value that is passed to the localFinally delegate. The localFinally delegate is invoked once per thread to perform a final action on each thread's local state.

Exceptions

Exception | Condition
System..::.ArgumentNullException | The exception that is thrown when the body argument is null.
System..::.ArgumentNullException | The exception that is thrown when the localInit argument is null.
System..::.ArgumentNullException | The exception that is thrown when the localFinally argument is null.
System..::.ArgumentNullException | The exception that is thrown when the parallelOptions argument is null.
System..::.OperationCanceledException | The exception that is thrown when the CancellationToken in the parallelOptions argument is set.
System..::.AggregateException | The exception that is thrown to contain an exception thrown from one of the specified delegates.
System..::.ObjectDisposedException | The exception that is thrown when the the CancellationTokenSource associated with the the CancellationToken in the parallelOptions has been disposed.

See Also

Parallel Class
For Overload
System.Threading.Tasks Namespace


For(TLocal) Method (Int64, Int64, ParallelOptions, Func(TLocal), Func(Int64, ParallelLoopState, TLocal, TLocal), Action(TLocal))

[image]

.NET Framework Class Library
Parallel..::.For<(Of <(TLocal>)>) Method (Int64, Int64, ParallelOptions, Func<(Of <(TLocal>)>), Func<(Of <(Int64, ParallelLoopState, TLocal, TLocal>)>), Action<(Of <(TLocal>)>))
Parallel Class See Also Send Feedback

Executes a for loop in which iterations may run in parallel.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function For(Of TLocal) ( _
    fromInclusive As Long, _
    toExclusive As Long, _
    parallelOptions As ParallelOptions, _
    localInit As Func(Of TLocal), _
    body As Func(Of Long, ParallelLoopState, TLocal, TLocal), _
    localFinally As Action(Of TLocal) _
) As ParallelLoopResult
C#
public static ParallelLoopResult For<TLocal>(
    long fromInclusive,
    long toExclusive,
    ParallelOptions parallelOptions,
    Func<TLocal> localInit,
    Func<long, ParallelLoopState, TLocal, TLocal> body,
    Action<TLocal> localFinally
)

Parameters

fromInclusive
Type: System..::.Int64
The start index, inclusive.
toExclusive
Type: System..::.Int64
The end index, exclusive.
parallelOptions
Type: System.Threading.Tasks..::.ParallelOptions
A ParallelOptions instance that configures the behavior of this operation.
localInit
Type: System..::.Func<(Of <(TLocal>)>)
The function delegate that returns the initial state of the local data for each thread.
body
Type: System..::.Func<(Of <(Int64, ParallelLoopState, TLocal, TLocal>)>)
The delegate that is invoked once per iteration.
localFinally
Type: System..::.Action<(Of <(TLocal>)>)
The delegate that performs a final action on the local state of each thread.

Type Parameters

TLocal
The type of the thread-local data.

Return Value

A ParallelLoopResult structure that contains information on what portion of the loop completed.

Remarks

The body delegate is invoked once for each value in the iteration range: [fromInclusive, toExclusive). It is provided with the following parameters: the iteration count (an Int64), a ParallelLoopState instance that may be used to break out of the loop prematurely, and some local state that may be shared amongst iterations that execute on the same thread.

The localInit delegate is invoked once for each thread that participates in the loop's execution and returns the initial local state for each of those threads. These initial states are passed to the first body invocations on each thread. Then, every subsequent body invocation returns a possibly modified state value that is passed to the next body invocation. Finally, the last body invocation on each thread returns a state value that is passed to the localFinally delegate. The localFinally delegate is invoked once per thread to perform a final action on each thread's local state.

Exceptions

Exception | Condition
System..::.ArgumentNullException | The exception that is thrown when the body argument is null.
System..::.ArgumentNullException | The exception that is thrown when the localInit argument is null.
System..::.ArgumentNullException | The exception that is thrown when the localFinally argument is null.
System..::.ArgumentNullException | The exception that is thrown when the parallelOptions argument is null.
System..::.OperationCanceledException | The exception that is thrown when the CancellationToken in the parallelOptions argument is set.
System..::.AggregateException | The exception that is thrown to contain an exception thrown from one of the specified delegates.
System..::.ObjectDisposedException | The exception that is thrown when the the CancellationTokenSource associated with the the CancellationToken in the parallelOptions has been disposed.

See Also

Parallel Class
For Overload
System.Threading.Tasks Namespace


ForEach Method

[image] [image]

.NET Framework Class Library
Parallel..::.ForEach Method
Parallel Class See Also Send Feedback

Overload List

Name | Description
ForEach<(Of <(TSource>)>)(OrderablePartitioner<(Of <(TSource>)>), Action<(Of <(TSource, ParallelLoopState, Int64>)>)) | Executes a for each operation on a OrderablePartitioner in which iterations may run in parallel.
ForEach<(Of <(TSource>)>)(Partitioner<(Of <(TSource>)>), Action<(Of <(TSource>)>)) | Executes a for each operation on a Partitioner in which iterations may run in parallel.
ForEach<(Of <(TSource>)>)(Partitioner<(Of <(TSource>)>), Action<(Of <(TSource, ParallelLoopState>)>)) | Executes a for each operation on a Partitioner in which iterations may run in parallel.
ForEach<(Of <(TSource>)>)(IEnumerable<(Of <(TSource>)>), Action<(Of <(TSource>)>)) | Executes a for each operation on an IEnumerable<(Of <(TSource>)>) in which iterations may run in parallel.
ForEach<(Of <(TSource>)>)(IEnumerable<(Of <(TSource>)>), Action<(Of <(TSource, ParallelLoopState>)>)) | Executes a for each operation on an IEnumerable<(Of <(TSource>)>) in which iterations may run in parallel.
ForEach<(Of <(TSource>)>)(IEnumerable<(Of <(TSource>)>), Action<(Of <(TSource, ParallelLoopState, Int64>)>)) | Executes a for each operation on an IEnumerable<(Of <(TSource>)>) in which iterations may run in parallel.
ForEach<(Of <(TSource>)>)(OrderablePartitioner<(Of <(TSource>)>), ParallelOptions, Action<(Of <(TSource, ParallelLoopState, Int64>)>)) | Executes a for each operation on a OrderablePartitioner in which iterations may run in parallel.
ForEach<(Of <(TSource>)>)(Partitioner<(Of <(TSource>)>), ParallelOptions, Action<(Of <(TSource>)>)) | Executes a for each operation on a Partitioner in which iterations may run in parallel.
ForEach<(Of <(TSource>)>)(Partitioner<(Of <(TSource>)>), ParallelOptions, Action<(Of <(TSource, ParallelLoopState>)>)) | Executes a for each operation on a Partitioner in which iterations may run in parallel.
ForEach<(Of <(TSource>)>)(IEnumerable<(Of <(TSource>)>), ParallelOptions, Action<(Of <(TSource>)>)) | Executes a for each operation on an IEnumerable<(Of <(TSource>)>) in which iterations may run in parallel.
ForEach<(Of <(TSource>)>)(IEnumerable<(Of <(TSource>)>), ParallelOptions, Action<(Of <(TSource, ParallelLoopState>)>)) | Executes a for each operation on an IEnumerable<(Of <(TSource>)>) in which iterations may run in parallel.
ForEach<(Of <(TSource>)>)(IEnumerable<(Of <(TSource>)>), ParallelOptions, Action<(Of <(TSource, ParallelLoopState, Int64>)>)) | Executes a for each operation on an IEnumerable<(Of <(TSource>)>) in which iterations may run in parallel.
ForEach<(Of <(TSource, TLocal>)>)(OrderablePartitioner<(Of <(TSource>)>), Func<(Of <(TLocal>)>), Func<(Of <(TSource, ParallelLoopState, Int64, TLocal, TLocal>)>), Action<(Of <(TLocal>)>)) | Executes a for each operation on a OrderablePartitioner in which iterations may run in parallel.
ForEach<(Of <(TSource, TLocal>)>)(Partitioner<(Of <(TSource>)>), Func<(Of <(TLocal>)>), Func<(Of <(TSource, ParallelLoopState, TLocal, TLocal>)>), Action<(Of <(TLocal>)>)) | Executes a for each operation on a Partitioner in which iterations may run in parallel.
ForEach<(Of <(TSource, TLocal>)>)(IEnumerable<(Of <(TSource>)>), Func<(Of <(TLocal>)>), Func<(Of <(TSource, ParallelLoopState, TLocal, TLocal>)>), Action<(Of <(TLocal>)>)) | Executes a for each operation on an IEnumerable<(Of <(TSource>)>) in which iterations may run in parallel.
ForEach<(Of <(TSource, TLocal>)>)(IEnumerable<(Of <(TSource>)>), Func<(Of <(TLocal>)>), Func<(Of <(TSource, ParallelLoopState, Int64, TLocal, TLocal>)>), Action<(Of <(TLocal>)>)) | Executes a for each operation on an IEnumerable<(Of <(TSource>)>) in which iterations may run in parallel.
ForEach<(Of <(TSource, TLocal>)>)(OrderablePartitioner<(Of <(TSource>)>), ParallelOptions, Func<(Of <(TLocal>)>), Func<(Of <(TSource, ParallelLoopState, Int64, TLocal, TLocal>)>), Action<(Of <(TLocal>)>)) | Executes a for each operation on a OrderablePartitioner in which iterations may run in parallel.
ForEach<(Of <(TSource, TLocal>)>)(Partitioner<(Of <(TSource>)>), ParallelOptions, Func<(Of <(TLocal>)>), Func<(Of <(TSource, ParallelLoopState, TLocal, TLocal>)>), Action<(Of <(TLocal>)>)) | Executes a for each operation on a Partitioner in which iterations may run in parallel.
ForEach<(Of <(TSource, TLocal>)>)(IEnumerable<(Of <(TSource>)>), ParallelOptions, Func<(Of <(TLocal>)>), Func<(Of <(TSource, ParallelLoopState, TLocal, TLocal>)>), Action<(Of <(TLocal>)>)) | Executes a for each operation on an IEnumerable<(Of <(TSource>)>) in which iterations may run in parallel.
ForEach<(Of <(TSource, TLocal>)>)(IEnumerable<(Of <(TSource>)>), ParallelOptions, Func<(Of <(TLocal>)>), Func<(Of <(TSource, ParallelLoopState, Int64, TLocal, TLocal>)>), Action<(Of <(TLocal>)>)) | Executes a for each operation on an IEnumerable<(Of <(TSource>)>) in which iterations may run in parallel.

See Also

Parallel Class
System.Threading.Tasks Namespace


ForEach(TSource) Method (OrderablePartitioner(TSource), Action(TSource, ParallelLoopState, Int64))

[image]

.NET Framework Class Library
Parallel..::.ForEach<(Of <(TSource>)>) Method (OrderablePartitioner<(Of <(TSource>)>), Action<(Of <(TSource, ParallelLoopState, Int64>)>))
Parallel Class See Also Send Feedback

Executes a for each operation on a OrderablePartitioner in which iterations may run in parallel.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function ForEach(Of TSource) ( _
    source As OrderablePartitioner(Of TSource), _
    body As Action(Of TSource, ParallelLoopState, Long) _
) As ParallelLoopResult
C#
public static ParallelLoopResult ForEach<TSource>(
    OrderablePartitioner<TSource> source,
    Action<TSource, ParallelLoopState, long> body
)

Parameters

source
Type: System.Collections.Concurrent..::.OrderablePartitioner <(Of <(TSource>)>)
The OrderablePartitioner that contains the original data source.
body
Type: System..::.Action<(Of <(TSource, ParallelLoopState, Int64>)>)
The delegate that is invoked once per iteration.

Type Parameters

TSource
The type of the elements in source.

Return Value

A ParallelLoopResult structure that contains information on what portion of the loop completed.

Remarks

The Partitioner is used to retrieve the elements to be processed, in place of the original data source. If the current element's index is desired, the source must be an OrderablePartitioner.

The body delegate is invoked once for each element in the source Partitioner. It is provided with the following parameters: the current element, a ParallelLoopState instance that may be used to break out of the loop prematurely, and the current element's index (an Int64).

Exceptions

Exception | Condition
System..::.ArgumentNullException | The exception that is thrown when the source argument is null.
System..::.ArgumentNullException | The exception that is thrown when the body argument is null.
System..::.InvalidOperationException | The exception that is thrown when the SupportsDynamicPartitions property in the source OrderablePartitioner returns false.
System..::.InvalidOperationException | The exception that is thrown when the KeysNormalized property in the source OrderablePartitioner returns false.
System..::.InvalidOperationException | The exception that is thrown when any methods in the source OrderablePartitioner return null.
System..::.InvalidOperationException | The exception that is thrown when the GetPartitions() or GetOrderablePartitions() methods in the source OrderablePartitioner do not return the correct number of partitions.
System..::.InvalidOperationException | The exception that is thrown when the GetPartitions() or GetOrderablePartitions() methods in the source OrderablePartitioner return an IList with at least one null value.
System..::.InvalidOperationException | The exception that is thrown when the GetDynamicPartitions() or GetDynamicOrderablePartitions() methods in the source OrderablePartitioner return an IEnumerable whose GetEnumerator() method returns null.
System..::.AggregateException | The exception that is thrown to contain an exception thrown from one of the specified delegates.

See Also

Parallel Class
ForEach Overload
System.Threading.Tasks Namespace


ForEach(TSource) Method (Partitioner(TSource), Action(TSource))

[image]

.NET Framework Class Library
Parallel..::.ForEach<(Of <(TSource>)>) Method (Partitioner<(Of <(TSource>)>), Action<(Of <(TSource>)>))
Parallel Class See Also Send Feedback

Executes a for each operation on a Partitioner in which iterations may run in parallel.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function ForEach(Of TSource) ( _
    source As Partitioner(Of TSource), _
    body As Action(Of TSource) _
) As ParallelLoopResult
C#
public static ParallelLoopResult ForEach<TSource>(
    Partitioner<TSource> source,
    Action<TSource> body
)

Parameters

source
Type: System.Collections.Concurrent..::.Partitioner <(Of <(TSource>)>)
The Partitioner that contains the original data source.
body
Type: System..::.Action<(Of <(TSource>)>)
The delegate that is invoked once per iteration.

Type Parameters

TSource
The type of the elements in source.

Return Value

A ParallelLoopResult structure that contains information on what portion of the loop completed.

Remarks

The Partitioner is used to retrieve the elements to be processed, in place of the original data source. If the current element's index is desired, the source must be an OrderablePartitioner.

The body delegate is invoked once for each element in the source Partitioner. It is provided with the current element as a parameter.

Exceptions

Exception | Condition
System..::.ArgumentNullException | The exception that is thrown when the source argument is null.
System..::.ArgumentNullException | The exception that is thrown when the body argument is null.
System..::.InvalidOperationException | The exception that is thrown when the SupportsDynamicPartitions property in the source Partitioner returns false.
System..::.InvalidOperationException | The exception that is thrown when any methods in the source Partitioner return null.
System..::.InvalidOperationException | The exception that is thrown when the GetPartitions() method in the source Partitioner does not return the correct number of partitions.
System..::.InvalidOperationException | The exception that is thrown when the GetPartitions() method in the source Partitioner returns an IList with at least one null value.
System..::.InvalidOperationException | The exception that is thrown when the GetDynamicPartitions() method in the source Partitioner returns an IEnumerable whose GetEnumerator() method returns null.
System..::.AggregateException | The exception that is thrown to contain an exception thrown from one of the specified delegates.

See Also

Parallel Class
ForEach Overload
System.Threading.Tasks Namespace


ForEach(TSource) Method (Partitioner(TSource), Action(TSource, ParallelLoopState))

[image]

.NET Framework Class Library
Parallel..::.ForEach<(Of <(TSource>)>) Method (Partitioner<(Of <(TSource>)>), Action<(Of <(TSource, ParallelLoopState>)>))
Parallel Class See Also Send Feedback

Executes a for each operation on a Partitioner in which iterations may run in parallel.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function ForEach(Of TSource) ( _
    source As Partitioner(Of TSource), _
    body As Action(Of TSource, ParallelLoopState) _
) As ParallelLoopResult
C#
public static ParallelLoopResult ForEach<TSource>(
    Partitioner<TSource> source,
    Action<TSource, ParallelLoopState> body
)

Parameters

source
Type: System.Collections.Concurrent..::.Partitioner <(Of <(TSource>)>)
The Partitioner that contains the original data source.
body
Type: System..::.Action<(Of <(TSource, ParallelLoopState >)>)
The delegate that is invoked once per iteration.

Type Parameters

TSource
The type of the elements in source.

Return Value

A ParallelLoopResult structure that contains information on what portion of the loop completed.

Remarks

The Partitioner is used to retrieve the elements to be processed, in place of the original data source. If the current element's index is desired, the source must be an OrderablePartitioner.

The body delegate is invoked once for each element in the source Partitioner. It is provided with the following parameters: the current element, and a ParallelLoopState instance that may be used to break out of the loop prematurely.

Exceptions

Exception | Condition
System..::.ArgumentNullException | The exception that is thrown when the source argument is null.
System..::.ArgumentNullException | The exception that is thrown when the body argument is null.
System..::.InvalidOperationException | The exception that is thrown when the SupportsDynamicPartitions property in the source Partitioner returns false.
System..::.InvalidOperationException | The exception that is thrown when any methods in the source Partitioner return null.
System..::.InvalidOperationException | The exception that is thrown when the GetPartitions() method in the source Partitioner does not return the correct number of partitions.
System..::.InvalidOperationException | The exception that is thrown when the GetPartitions() method in the source Partitioner returns an IList with at least one null value.
System..::.InvalidOperationException | The exception that is thrown when the GetDynamicPartitions() method in the source Partitioner returns an IEnumerable whose GetEnumerator() method returns null.
System..::.AggregateException | The exception that is thrown to contain an exception thrown from one of the specified delegates.

See Also

Parallel Class
ForEach Overload
System.Threading.Tasks Namespace


ForEach(TSource) Method (IEnumerable(TSource), Action(TSource))

[image]

.NET Framework Class Library
Parallel..::.ForEach<(Of <(TSource>)>) Method (IEnumerable<(Of <(TSource>)>), Action<(Of <(TSource>)>))
Parallel Class See Also Send Feedback

Executes a for each operation on an IEnumerable<(Of <(TSource>)>) in which iterations may run in parallel.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function ForEach(Of TSource) ( _
    source As IEnumerable(Of TSource), _
    body As Action(Of TSource) _
) As ParallelLoopResult
C#
public static ParallelLoopResult ForEach<TSource>(
    IEnumerable<TSource> source,
    Action<TSource> body
)

Parameters

source
Type: System.Collections.Generic..::.IEnumerable<(Of <(TSource>)>)
An enumerable data source.
body
Type: System..::.Action<(Of <(TSource>)>)
The delegate that is invoked once per iteration.

Type Parameters

TSource
The type of the data in the source.

Return Value

A ParallelLoopResult structure that contains information on what portion of the loop completed.

Remarks

The body delegate is invoked once for each element in the source enumerable. It is provided with the current element as a parameter.

Exceptions

Exception | Condition
System..::.ArgumentNullException | The exception that is thrown when the source argument is null.
System..::.ArgumentNullException | The exception that is thrown when the body argument is null.
System..::.AggregateException | The exception that is thrown to contain an exception thrown from one of the specified delegates.

See Also

Parallel Class
ForEach Overload
System.Threading.Tasks Namespace


ForEach(TSource) Method (IEnumerable(TSource), Action(TSource, ParallelLoopState))

[image]

.NET Framework Class Library
Parallel..::.ForEach<(Of <(TSource>)>) Method (IEnumerable<(Of <(TSource>)>), Action<(Of <(TSource, ParallelLoopState>)>))
Parallel Class See Also Send Feedback

Executes a for each operation on an IEnumerable<(Of <(TSource>)>) in which iterations may run in parallel.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function ForEach(Of TSource) ( _
    source As IEnumerable(Of TSource), _
    body As Action(Of TSource, ParallelLoopState) _
) As ParallelLoopResult
C#
public static ParallelLoopResult ForEach<TSource>(
    IEnumerable<TSource> source,
    Action<TSource, ParallelLoopState> body
)

Parameters

source
Type: System.Collections.Generic..::.IEnumerable<(Of <(TSource>)>)
An enumerable data source.
body
Type: System..::.Action<(Of <(TSource, ParallelLoopState >)>)
The delegate that is invoked once per iteration.

Type Parameters

TSource
The type of the data in the source.

Return Value

A ParallelLoopResult structure that contains information on what portion of the loop completed.

Remarks

The body delegate is invoked once for each element in the source enumerable. It is provided with the following parameters: the current element, and a ParallelLoopState instance that may be used to break out of the loop prematurely.

Exceptions

Exception | Condition
System..::.ArgumentNullException | The exception that is thrown when the source argument is null.
System..::.ArgumentNullException | The exception that is thrown when the body argument is null.
System..::.AggregateException | The exception that is thrown to contain an exception thrown from one of the specified delegates.

See Also

Parallel Class
ForEach Overload
System.Threading.Tasks Namespace


ForEach(TSource) Method (IEnumerable(TSource), Action(TSource, ParallelLoopState, Int64))

[image]

.NET Framework Class Library
Parallel..::.ForEach<(Of <(TSource>)>) Method (IEnumerable<(Of <(TSource>)>), Action<(Of <(TSource, ParallelLoopState, Int64>)>))
Parallel Class See Also Send Feedback

Executes a for each operation on an IEnumerable<(Of <(TSource>)>) in which iterations may run in parallel.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function ForEach(Of TSource) ( _
    source As IEnumerable(Of TSource), _
    body As Action(Of TSource, ParallelLoopState, Long) _
) As ParallelLoopResult
C#
public static ParallelLoopResult ForEach<TSource>(
    IEnumerable<TSource> source,
    Action<TSource, ParallelLoopState, long> body
)

Parameters

source
Type: System.Collections.Generic..::.IEnumerable<(Of <(TSource>)>)
An enumerable data source.
body
Type: System..::.Action<(Of <(TSource, ParallelLoopState, Int64>)>)
The delegate that is invoked once per iteration.

Type Parameters

TSource
The type of the data in the source.

Return Value

A ParallelLoopResult structure that contains information on what portion of the loop completed.

Remarks

The body delegate is invoked once for each element in the source enumerable. It is provided with the following parameters: the current element, a ParallelLoopState instance that may be used to break out of the loop prematurely, and the current element's index (an Int64).

Exceptions

Exception | Condition
System..::.ArgumentNullException | The exception that is thrown when the source argument is null.
System..::.ArgumentNullException | The exception that is thrown when the body argument is null.
System..::.AggregateException | The exception that is thrown to contain an exception thrown from one of the specified delegates.

See Also

Parallel Class
ForEach Overload
System.Threading.Tasks Namespace


ForEach(TSource) Method (OrderablePartitioner(TSource), ParallelOptions, Action(TSource, ParallelLoopState, Int64))

[image]

.NET Framework Class Library
Parallel..::.ForEach<(Of <(TSource>)>) Method (OrderablePartitioner<(Of <(TSource>)>), ParallelOptions, Action<(Of <(TSource, ParallelLoopState, Int64>)>))
Parallel Class See Also Send Feedback

Executes a for each operation on a OrderablePartitioner in which iterations may run in parallel.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function ForEach(Of TSource) ( _
    source As OrderablePartitioner(Of TSource), _
    parallelOptions As ParallelOptions, _
    body As Action(Of TSource, ParallelLoopState, Long) _
) As ParallelLoopResult
C#
public static ParallelLoopResult ForEach<TSource>(
    OrderablePartitioner<TSource> source,
    ParallelOptions parallelOptions,
    Action<TSource, ParallelLoopState, long> body
)

Parameters

source
Type: System.Collections.Concurrent..::.OrderablePartitioner <(Of <(TSource>)>)
The OrderablePartitioner that contains the original data source.
parallelOptions
Type: System.Threading.Tasks..::.ParallelOptions
A ParallelOptions instance that configures the behavior of this operation.
body
Type: System..::.Action<(Of <(TSource, ParallelLoopState, Int64>)>)
The delegate that is invoked once per iteration.

Type Parameters

TSource
The type of the elements in source.

Return Value

A ParallelLoopResult structure that contains information on what portion of the loop completed.

Remarks

The Partitioner is used to retrieve the elements to be processed, in place of the original data source. If the current element's index is desired, the source must be an OrderablePartitioner.

The body delegate is invoked once for each element in the source Partitioner. It is provided with the following parameters: the current element, a ParallelLoopState instance that may be used to break out of the loop prematurely, and the current element's index (an Int64).

Exceptions

Exception | Condition
System..::.ArgumentNullException | The exception that is thrown when the source argument is null.
System..::.ArgumentNullException | The exception that is thrown when the parallelOptions argument is null.
System..::.ArgumentNullException | The exception that is thrown when the body argument is null.
System..::.OperationCanceledException | The exception that is thrown when the CancellationToken in the parallelOptions argument is set
System..::.InvalidOperationException | The exception that is thrown when the SupportsDynamicPartitions property in the source OrderablePartitioner returns false.
System..::.InvalidOperationException | The exception that is thrown when the KeysNormalized property in the source OrderablePartitioner returns false.
System..::.InvalidOperationException | The exception that is thrown when any methods in the source OrderablePartitioner return null.
System..::.InvalidOperationException | The exception that is thrown when the GetPartitions() or GetOrderablePartitions() methods in the source OrderablePartitioner do not return the correct number of partitions.
System..::.InvalidOperationException | The exception that is thrown when the GetPartitions() or GetOrderablePartitions() methods in the source OrderablePartitioner return an IList with at least one null value.
System..::.InvalidOperationException | The exception that is thrown when the GetDynamicPartitions() or GetDynamicOrderablePartitions() methods in the source OrderablePartitioner return an IEnumerable whose GetEnumerator() method returns null.
System..::.AggregateException | The exception that is thrown to contain an exception thrown from one of the specified delegates.
System..::.ObjectDisposedException | The exception that is thrown when the the CancellationTokenSource associated with the the CancellationToken in the parallelOptions has been disposed.

See Also

Parallel Class
ForEach Overload
System.Threading.Tasks Namespace


ForEach(TSource) Method (Partitioner(TSource), ParallelOptions, Action(TSource))

[image]

.NET Framework Class Library
Parallel..::.ForEach<(Of <(TSource>)>) Method (Partitioner<(Of <(TSource>)>), ParallelOptions, Action<(Of <(TSource>)>))
Parallel Class See Also Send Feedback

Executes a for each operation on a Partitioner in which iterations may run in parallel.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function ForEach(Of TSource) ( _
    source As Partitioner(Of TSource), _
    parallelOptions As ParallelOptions, _
    body As Action(Of TSource) _
) As ParallelLoopResult
C#
public static ParallelLoopResult ForEach<TSource>(
    Partitioner<TSource> source,
    ParallelOptions parallelOptions,
    Action<TSource> body
)

Parameters

source
Type: System.Collections.Concurrent..::.Partitioner <(Of <(TSource>)>)
The Partitioner that contains the original data source.
parallelOptions
Type: System.Threading.Tasks..::.ParallelOptions
A ParallelOptions instance that configures the behavior of this operation.
body
Type: System..::.Action<(Of <(TSource>)>)
The delegate that is invoked once per iteration.

Type Parameters

TSource
The type of the elements in source.

Return Value

A ParallelLoopResult structure that contains information on what portion of the loop completed.

Remarks

The Partitioner is used to retrieve the elements to be processed, in place of the original data source. If the current element's index is desired, the source must be an OrderablePartitioner.

The body delegate is invoked once for each element in the source Partitioner. It is provided with the current element as a parameter.

Exceptions

Exception | Condition
System..::.ArgumentNullException | The exception that is thrown when the source argument is null.
System..::.ArgumentNullException | The exception that is thrown when the parallelOptions argument is null.
System..::.ArgumentNullException | The exception that is thrown when the body argument is null.
System..::.OperationCanceledException | The exception that is thrown when the CancellationToken in the parallelOptions argument is set
System..::.InvalidOperationException | The exception that is thrown when the SupportsDynamicPartitions property in the source Partitioner returns false.
System..::.InvalidOperationException | The exception that is thrown when any methods in the source Partitioner return null.
System..::.InvalidOperationException | The exception that is thrown when the GetPartitions() method in the source Partitioner does not return the correct number of partitions.
System..::.InvalidOperationException | The exception that is thrown when the GetPartitions() method in the source Partitioner returns an IList with at least one null value.
System..::.InvalidOperationException | The exception that is thrown when the GetDynamicPartitions() method in the source Partitioner returns an IEnumerable whose GetEnumerator() method returns null.
System..::.AggregateException | The exception that is thrown to contain an exception thrown from one of the specified delegates.
System..::.ObjectDisposedException | The exception that is thrown when the the CancellationTokenSource associated with the the CancellationToken in the parallelOptions has been disposed.

See Also

Parallel Class
ForEach Overload
System.Threading.Tasks Namespace


ForEach(TSource) Method (Partitioner(TSource), ParallelOptions, Action(TSource, ParallelLoopState))

[image]

.NET Framework Class Library
Parallel..::.ForEach<(Of <(TSource>)>) Method (Partitioner<(Of <(TSource>)>), ParallelOptions, Action<(Of <(TSource, ParallelLoopState>)>))
Parallel Class See Also Send Feedback

Executes a for each operation on a Partitioner in which iterations may run in parallel.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function ForEach(Of TSource) ( _
    source As Partitioner(Of TSource), _
    parallelOptions As ParallelOptions, _
    body As Action(Of TSource, ParallelLoopState) _
) As ParallelLoopResult
C#
public static ParallelLoopResult ForEach<TSource>(
    Partitioner<TSource> source,
    ParallelOptions parallelOptions,
    Action<TSource, ParallelLoopState> body
)

Parameters

source
Type: System.Collections.Concurrent..::.Partitioner <(Of <(TSource>)>)
The Partitioner that contains the original data source.
parallelOptions
Type: System.Threading.Tasks..::.ParallelOptions
A ParallelOptions instance that configures the behavior of this operation.
body
Type: System..::.Action<(Of <(TSource, ParallelLoopState >)>)
The delegate that is invoked once per iteration.

Type Parameters

TSource
The type of the elements in source.

Return Value

A ParallelLoopResult structure that contains information on what portion of the loop completed.

Remarks

The Partitioner is used to retrieve the elements to be processed, in place of the original data source. If the current element's index is desired, the source must be an OrderablePartitioner.

The body delegate is invoked once for each element in the source Partitioner. It is provided with the following parameters: the current element, and a ParallelLoopState instance that may be used to break out of the loop prematurely.

Exceptions

Exception | Condition
System..::.ArgumentNullException | The exception that is thrown when the source argument is null.
System..::.ArgumentNullException | The exception that is thrown when the parallelOptions argument is null.
System..::.ArgumentNullException | The exception that is thrown when the body argument is null.
System..::.OperationCanceledException | The exception that is thrown when the CancellationToken in the parallelOptions argument is set
System..::.InvalidOperationException | The exception that is thrown when the SupportsDynamicPartitions property in the source Partitioner returns false.
System..::.InvalidOperationException | The exception that is thrown when any methods in the source Partitioner return null.
System..::.InvalidOperationException | The exception that is thrown when the GetPartitions() method in the source Partitioner does not return the correct number of partitions.
System..::.InvalidOperationException | The exception that is thrown when the GetPartitions() method in the source Partitioner returns an IList with at least one null value.
System..::.InvalidOperationException | The exception that is thrown when the GetDynamicPartitions() method in the source Partitioner returns an IEnumerable whose GetEnumerator() method returns null.
System..::.AggregateException | The exception that is thrown to contain an exception thrown from one of the specified delegates.
System..::.ObjectDisposedException | The exception that is thrown when the the CancellationTokenSource associated with the the CancellationToken in the parallelOptions has been disposed.

See Also

Parallel Class
ForEach Overload
System.Threading.Tasks Namespace


ForEach(TSource) Method (IEnumerable(TSource), ParallelOptions, Action(TSource))

[image]

.NET Framework Class Library
Parallel..::.ForEach<(Of <(TSource>)>) Method (IEnumerable<(Of <(TSource>)>), ParallelOptions, Action<(Of <(TSource>)>))
Parallel Class See Also Send Feedback

Executes a for each operation on an IEnumerable<(Of <(TSource>)>) in which iterations may run in parallel.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function ForEach(Of TSource) ( _
    source As IEnumerable(Of TSource), _
    parallelOptions As ParallelOptions, _
    body As Action(Of TSource) _
) As ParallelLoopResult
C#
public static ParallelLoopResult ForEach<TSource>(
    IEnumerable<TSource> source,
    ParallelOptions parallelOptions,
    Action<TSource> body
)

Parameters

source
Type: System.Collections.Generic..::.IEnumerable<(Of <(TSource>)>)
An enumerable data source.
parallelOptions
Type: System.Threading.Tasks..::.ParallelOptions
A ParallelOptions instance that configures the behavior of this operation.
body
Type: System..::.Action<(Of <(TSource>)>)
The delegate that is invoked once per iteration.

Type Parameters

TSource
The type of the data in the source.

Return Value

A ParallelLoopResult structure that contains information on what portion of the loop completed.

Remarks

The body delegate is invoked once for each element in the source enumerable. It is provided with the current element as a parameter.

Exceptions

Exception | Condition
System..::.ArgumentNullException | The exception that is thrown when the source argument is null.
System..::.ArgumentNullException | The exception that is thrown when the parallelOptions argument is null.
System..::.ArgumentNullException | The exception that is thrown when the body argument is null.
System..::.OperationCanceledException | The exception that is thrown when the CancellationToken in the parallelOptions argument is set
System..::.AggregateException | The exception that is thrown to contain an exception thrown from one of the specified delegates.
System..::.ObjectDisposedException | The exception that is thrown when the the CancellationTokenSource associated with the the CancellationToken in the parallelOptions has been disposed.

See Also

Parallel Class
ForEach Overload
System.Threading.Tasks Namespace


ForEach(TSource) Method (IEnumerable(TSource), ParallelOptions, Action(TSource, ParallelLoopState))

[image]

.NET Framework Class Library
Parallel..::.ForEach<(Of <(TSource>)>) Method (IEnumerable<(Of <(TSource>)>), ParallelOptions, Action<(Of <(TSource, ParallelLoopState>)>))
Parallel Class See Also Send Feedback

Executes a for each operation on an IEnumerable<(Of <(TSource>)>) in which iterations may run in parallel.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function ForEach(Of TSource) ( _
    source As IEnumerable(Of TSource), _
    parallelOptions As ParallelOptions, _
    body As Action(Of TSource, ParallelLoopState) _
) As ParallelLoopResult
C#
public static ParallelLoopResult ForEach<TSource>(
    IEnumerable<TSource> source,
    ParallelOptions parallelOptions,
    Action<TSource, ParallelLoopState> body
)

Parameters

source
Type: System.Collections.Generic..::.IEnumerable<(Of <(TSource>)>)
An enumerable data source.
parallelOptions
Type: System.Threading.Tasks..::.ParallelOptions
A ParallelOptions instance that configures the behavior of this operation.
body
Type: System..::.Action<(Of <(TSource, ParallelLoopState >)>)
The delegate that is invoked once per iteration.

Type Parameters

TSource
The type of the data in the source.

Return Value

A ParallelLoopResult structure that contains information on what portion of the loop completed.

Remarks

The body delegate is invoked once for each element in the source enumerable. It is provided with the following parameters: the current element, and a ParallelLoopState instance that may be used to break out of the loop prematurely.

Exceptions

Exception | Condition
System..::.ArgumentNullException | The exception that is thrown when the source argument is null.
System..::.ArgumentNullException | The exception that is thrown when the parallelOptions argument is null.
System..::.ArgumentNullException | The exception that is thrown when the body argument is null.
System..::.OperationCanceledException | The exception that is thrown when the CancellationToken in the parallelOptions argument is set
System..::.AggregateException | The exception that is thrown to contain an exception thrown from one of the specified delegates.
System..::.ObjectDisposedException | The exception that is thrown when the the CancellationTokenSource associated with the the CancellationToken in the parallelOptions has been disposed.

See Also

Parallel Class
ForEach Overload
System.Threading.Tasks Namespace


ForEach(TSource) Method (IEnumerable(TSource), ParallelOptions, Action(TSource, ParallelLoopState, Int64))

[image]

.NET Framework Class Library
Parallel..::.ForEach<(Of <(TSource>)>) Method (IEnumerable<(Of <(TSource>)>), ParallelOptions, Action<(Of <(TSource, ParallelLoopState, Int64>)>))
Parallel Class See Also Send Feedback

Executes a for each operation on an IEnumerable<(Of <(TSource>)>) in which iterations may run in parallel.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function ForEach(Of TSource) ( _
    source As IEnumerable(Of TSource), _
    parallelOptions As ParallelOptions, _
    body As Action(Of TSource, ParallelLoopState, Long) _
) As ParallelLoopResult
C#
public static ParallelLoopResult ForEach<TSource>(
    IEnumerable<TSource> source,
    ParallelOptions parallelOptions,
    Action<TSource, ParallelLoopState, long> body
)

Parameters

source
Type: System.Collections.Generic..::.IEnumerable<(Of <(TSource>)>)
An enumerable data source.
parallelOptions
Type: System.Threading.Tasks..::.ParallelOptions
A ParallelOptions instance that configures the behavior of this operation.
body
Type: System..::.Action<(Of <(TSource, ParallelLoopState, Int64>)>)
The delegate that is invoked once per iteration.

Type Parameters

TSource
The type of the data in the source.

Return Value

A ParallelLoopResult structure that contains information on what portion of the loop completed.

Remarks

The body delegate is invoked once for each element in the source enumerable. It is provided with the following parameters: the current element, a ParallelLoopState instance that may be used to break out of the loop prematurely, and the current element's index (an Int64).

Exceptions

Exception | Condition
System..::.ArgumentNullException | The exception that is thrown when the source argument is null.
System..::.ArgumentNullException | The exception that is thrown when the parallelOptions argument is null.
System..::.ArgumentNullException | The exception that is thrown when the body argument is null.
System..::.OperationCanceledException | The exception that is thrown when the CancellationToken in the parallelOptions argument is set
System..::.AggregateException | The exception that is thrown to contain an exception thrown from one of the specified delegates.
System..::.ObjectDisposedException | The exception that is thrown when the the CancellationTokenSource associated with the the CancellationToken in the parallelOptions has been disposed.

See Also

Parallel Class
ForEach Overload
System.Threading.Tasks Namespace


ForEach(TSource, TLocal) Method (OrderablePartitioner(TSource), Func(TLocal), Func(TSource, ParallelLoopState, Int64, TLocal, TLocal), Action(TLocal))

[image]

.NET Framework Class Library
Parallel..::.ForEach<(Of <(TSource, TLocal>)>) Method (OrderablePartitioner<(Of <(TSource>)>), Func<(Of <(TLocal>)>), Func<(Of <(TSource, ParallelLoopState, Int64, TLocal, TLocal>)>), Action<(Of <(TLocal>)>))
Parallel Class See Also Send Feedback

Executes a for each operation on a OrderablePartitioner in which iterations may run in parallel.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function ForEach(Of TSource, TLocal) ( _
    source As OrderablePartitioner(Of TSource), _
    localInit As Func(Of TLocal), _
    body As Func(Of TSource, ParallelLoopState, Long, TLocal, TLocal), _
    localFinally As Action(Of TLocal) _
) As ParallelLoopResult
C#
public static ParallelLoopResult ForEach<TSource, TLocal>(
    OrderablePartitioner<TSource> source,
    Func<TLocal> localInit,
    Func<TSource, ParallelLoopState, long, TLocal, TLocal> body,
    Action<TLocal> localFinally
)

Parameters

source
Type: System.Collections.Concurrent..::.OrderablePartitioner <(Of <(TSource>)>)
The OrderablePartitioner that contains the original data source.
localInit
Type: System..::.Func<(Of <(TLocal>)>)
The function delegate that returns the initial state of the local data for each thread.
body
Type: System..::.Func<(Of <(TSource, ParallelLoopState, Int64, TLocal, TLocal>)>)
The delegate that is invoked once per iteration.
localFinally
Type: System..::.Action<(Of <(TLocal>)>)
The delegate that performs a final action on the local state of each thread.

Type Parameters

TSource
The type of the elements in source.
TLocal
The type of the thread-local data.

Return Value

A ParallelLoopResult structure that contains information on what portion of the loop completed.

Remarks

The Partitioner is used to retrieve the elements to be processed, in place of the original data source. If the current element's index is desired, the source must be an OrderablePartitioner.

The body delegate is invoked once for each element in the source Partitioner. It is provided with the following parameters: the current element, a ParallelLoopState instance that may be used to break out of the loop prematurely, the current element's index (an Int64), and some local state that may be shared amongst iterations that execute on the same thread.

The localInit delegate is invoked once for each thread that participates in the loop's execution and returns the initial local state for each of those threads. These initial states are passed to the first body invocations on each thread. Then, every subsequent body invocation returns a possibly modified state value that is passed to the next body invocation. Finally, the last body invocation on each thread returns a state value that is passed to the localFinally delegate. The localFinally delegate is invoked once per thread to perform a final action on each thread's local state.

Exceptions

Exception | Condition
System..::.ArgumentNullException | The exception that is thrown when the source argument is null.
System..::.ArgumentNullException | The exception that is thrown when the body argument is null.
System..::.ArgumentNullException | The exception that is thrown when the localInit argument is null.
System..::.ArgumentNullException | The exception that is thrown when the localFinally argument is null.
System..::.InvalidOperationException | The exception that is thrown when the SupportsDynamicPartitions property in the source OrderablePartitioner returns false.
System..::.InvalidOperationException | The exception that is thrown when the KeysNormalized property in the source OrderablePartitioner returns false.
System..::.InvalidOperationException | The exception that is thrown when any methods in the source OrderablePartitioner return null.
System..::.InvalidOperationException | The exception that is thrown when the GetPartitions() or GetOrderablePartitions() methods in the source OrderablePartitioner do not return the correct number of partitions.
System..::.InvalidOperationException | The exception that is thrown when the GetPartitions() or GetOrderablePartitions() methods in the source OrderablePartitioner return an IList with at least one null value.
System..::.InvalidOperationException | The exception that is thrown when the GetDynamicPartitions() or GetDynamicOrderablePartitions() methods in the source OrderablePartitioner return an IEnumerable whose GetEnumerator() method returns null.
System..::.AggregateException | The exception that is thrown to contain an exception thrown from one of the specified delegates.

See Also

Parallel Class
ForEach Overload
System.Threading.Tasks Namespace


ForEach(TSource, TLocal) Method (Partitioner(TSource), Func(TLocal), Func(TSource, ParallelLoopState, TLocal, TLocal), Action(TLocal))

[image]

.NET Framework Class Library
Parallel..::.ForEach<(Of <(TSource, TLocal>)>) Method (Partitioner<(Of <(TSource>)>), Func<(Of <(TLocal>)>), Func<(Of <(TSource, ParallelLoopState, TLocal, TLocal>)>), Action<(Of <(TLocal>)>))
Parallel Class See Also Send Feedback

Executes a for each operation on a Partitioner in which iterations may run in parallel.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function ForEach(Of TSource, TLocal) ( _
    source As Partitioner(Of TSource), _
    localInit As Func(Of TLocal), _
    body As Func(Of TSource, ParallelLoopState, TLocal, TLocal), _
    localFinally As Action(Of TLocal) _
) As ParallelLoopResult
C#
public static ParallelLoopResult ForEach<TSource, TLocal>(
    Partitioner<TSource> source,
    Func<TLocal> localInit,
    Func<TSource, ParallelLoopState, TLocal, TLocal> body,
    Action<TLocal> localFinally
)

Parameters

source
Type: System.Collections.Concurrent..::.Partitioner <(Of <(TSource>)>)
The Partitioner that contains the original data source.
localInit
Type: System..::.Func<(Of <(TLocal>)>)
The function delegate that returns the initial state of the local data for each thread.
body
Type: System..::.Func<(Of <(TSource, ParallelLoopState, TLocal, TLocal>)>)
The delegate that is invoked once per iteration.
localFinally
Type: System..::.Action<(Of <(TLocal>)>)
The delegate that performs a final action on the local state of each thread.

Type Parameters

TSource
The type of the elements in source.
TLocal
The type of the thread-local data.

Return Value

A ParallelLoopResult structure that contains information on what portion of the loop completed.

Remarks

The Partitioner is used to retrieve the elements to be processed, in place of the original data source. If the current element's index is desired, the source must be an OrderablePartitioner.

The body delegate is invoked once for each element in the source Partitioner. It is provided with the following parameters: the current element, a ParallelLoopState instance that may be used to break out of the loop prematurely, and some local state that may be shared amongst iterations that execute on the same thread.

The localInit delegate is invoked once for each thread that participates in the loop's execution and returns the initial local state for each of those threads. These initial states are passed to the first body invocations on each thread. Then, every subsequent body invocation returns a possibly modified state value that is passed to the next body invocation. Finally, the last body invocation on each thread returns a state value that is passed to the localFinally delegate. The localFinally delegate is invoked once per thread to perform a final action on each thread's local state.

Exceptions

Exception | Condition
System..::.ArgumentNullException | The exception that is thrown when the source argument is null.
System..::.ArgumentNullException | The exception that is thrown when the body argument is null.
System..::.ArgumentNullException | The exception that is thrown when the localInit argument is null.
System..::.ArgumentNullException | The exception that is thrown when the localFinally argument is null.
System..::.InvalidOperationException | The exception that is thrown when the SupportsDynamicPartitions property in the source Partitioner returns false.
System..::.InvalidOperationException | The exception that is thrown when any methods in the source Partitioner return null.
System..::.InvalidOperationException | The exception that is thrown when the GetPartitions() method in the source Partitioner does not return the correct number of partitions.
System..::.InvalidOperationException | The exception that is thrown when the GetPartitions() method in the source Partitioner returns an IList with at least one null value.
System..::.InvalidOperationException | The exception that is thrown when the GetDynamicPartitions() method in the source Partitioner returns an IEnumerable whose GetEnumerator() method returns null.
System..::.AggregateException | The exception that is thrown to contain an exception thrown from one of the specified delegates.

See Also

Parallel Class
ForEach Overload
System.Threading.Tasks Namespace


ForEach(TSource, TLocal) Method (IEnumerable(TSource), Func(TLocal), Func(TSource, ParallelLoopState, TLocal, TLocal), Action(TLocal))

[image]

.NET Framework Class Library
Parallel..::.ForEach<(Of <(TSource, TLocal>)>) Method (IEnumerable<(Of <(TSource>)>), Func<(Of <(TLocal>)>), Func<(Of <(TSource, ParallelLoopState, TLocal, TLocal>)>), Action<(Of <(TLocal>)>))
Parallel Class See Also Send Feedback

Executes a for each operation on an IEnumerable<(Of <(TSource>)>) in which iterations may run in parallel.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function ForEach(Of TSource, TLocal) ( _
    source As IEnumerable(Of TSource), _
    localInit As Func(Of TLocal), _
    body As Func(Of TSource, ParallelLoopState, TLocal, TLocal), _
    localFinally As Action(Of TLocal) _
) As ParallelLoopResult
C#
public static ParallelLoopResult ForEach<TSource, TLocal>(
    IEnumerable<TSource> source,
    Func<TLocal> localInit,
    Func<TSource, ParallelLoopState, TLocal, TLocal> body,
    Action<TLocal> localFinally
)

Parameters

source
Type: System.Collections.Generic..::.IEnumerable<(Of <(TSource>)>)
An enumerable data source.
localInit
Type: System..::.Func<(Of <(TLocal>)>)
The function delegate that returns the initial state of the local data for each thread.
body
Type: System..::.Func<(Of <(TSource, ParallelLoopState, TLocal, TLocal>)>)
The delegate that is invoked once per iteration.
localFinally
Type: System..::.Action<(Of <(TLocal>)>)
The delegate that performs a final action on the local state of each thread.

Type Parameters

TSource
The type of the data in the source.
TLocal
The type of the thread-local data.

Return Value

A ParallelLoopResult structure that contains information on what portion of the loop completed.

Remarks

The body delegate is invoked once for each element in the source enumerable. It is provided with the following parameters: the current element, a ParallelLoopState instance that may be used to break out of the loop prematurely, and some local state that may be shared amongst iterations that execute on the same thread.

The localInit delegate is invoked once for each thread that participates in the loop's execution and returns the initial local state for each of those threads. These initial states are passed to the first body invocations on each thread. Then, every subsequent body invocation returns a possibly modified state value that is passed to the next body invocation. Finally, the last body invocation on each thread returns a state value that is passed to the localFinally delegate. The localFinally delegate is invoked once per thread to perform a final action on each thread's local state.

Exceptions

Exception | Condition
System..::.ArgumentNullException | The exception that is thrown when the source argument is null.
System..::.ArgumentNullException | The exception that is thrown when the body argument is null.
System..::.ArgumentNullException | The exception that is thrown when the localInit argument is null.
System..::.ArgumentNullException | The exception that is thrown when the localFinally argument is null.
System..::.AggregateException | The exception that is thrown to contain an exception thrown from one of the specified delegates.

See Also

Parallel Class
ForEach Overload
System.Threading.Tasks Namespace


ForEach(TSource, TLocal) Method (IEnumerable(TSource), Func(TLocal), Func(TSource, ParallelLoopState, Int64, TLocal, TLocal), Action(TLocal))

[image]

.NET Framework Class Library
Parallel..::.ForEach<(Of <(TSource, TLocal>)>) Method (IEnumerable<(Of <(TSource>)>), Func<(Of <(TLocal>)>), Func<(Of <(TSource, ParallelLoopState, Int64, TLocal, TLocal>)>), Action<(Of <(TLocal>)>))
Parallel Class See Also Send Feedback

Executes a for each operation on an IEnumerable<(Of <(TSource>)>) in which iterations may run in parallel.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function ForEach(Of TSource, TLocal) ( _
    source As IEnumerable(Of TSource), _
    localInit As Func(Of TLocal), _
    body As Func(Of TSource, ParallelLoopState, Long, TLocal, TLocal), _
    localFinally As Action(Of TLocal) _
) As ParallelLoopResult
C#
public static ParallelLoopResult ForEach<TSource, TLocal>(
    IEnumerable<TSource> source,
    Func<TLocal> localInit,
    Func<TSource, ParallelLoopState, long, TLocal, TLocal> body,
    Action<TLocal> localFinally
)

Parameters

source
Type: System.Collections.Generic..::.IEnumerable<(Of <(TSource>)>)
An enumerable data source.
localInit
Type: System..::.Func<(Of <(TLocal>)>)
The function delegate that returns the initial state of the local data for each thread.
body
Type: System..::.Func<(Of <(TSource, ParallelLoopState, Int64, TLocal, TLocal>)>)
The delegate that is invoked once per iteration.
localFinally
Type: System..::.Action<(Of <(TLocal>)>)
The delegate that performs a final action on the local state of each thread.

Type Parameters

TSource
The type of the data in the source.
TLocal
The type of the thread-local data.

Return Value

A ParallelLoopResult structure that contains information on what portion of the loop completed.

Remarks

The body delegate is invoked once for each element in the source enumerable. It is provided with the following parameters: the current element, a ParallelLoopState instance that may be used to break out of the loop prematurely, the current element's index (an Int64), and some local state that may be shared amongst iterations that execute on the same thread.

The localInit delegate is invoked once for each thread that participates in the loop's execution and returns the initial local state for each of those threads. These initial states are passed to the first body invocations on each thread. Then, every subsequent body invocation returns a possibly modified state value that is passed to the next body invocation. Finally, the last body invocation on each thread returns a state value that is passed to the localFinally delegate. The localFinally delegate is invoked once per thread to perform a final action on each thread's local state.

Exceptions

Exception | Condition
System..::.ArgumentNullException | The exception that is thrown when the source argument is null.
System..::.ArgumentNullException | The exception that is thrown when the body argument is null.
System..::.ArgumentNullException | The exception that is thrown when the localInit argument is null.
System..::.ArgumentNullException | The exception that is thrown when the localFinally argument is null.
System..::.AggregateException | The exception that is thrown to contain an exception thrown from one of the specified delegates.

See Also

Parallel Class
ForEach Overload
System.Threading.Tasks Namespace


ForEach(TSource, TLocal) Method (OrderablePartitioner(TSource), ParallelOptions, Func(TLocal), Func(TSource, ParallelLoopState, Int64, TLocal, TLocal), Action(TLocal))

[image]

.NET Framework Class Library
Parallel..::.ForEach<(Of <(TSource, TLocal>)>) Method (OrderablePartitioner<(Of <(TSource>)>), ParallelOptions, Func<(Of <(TLocal>)>), Func<(Of <(TSource, ParallelLoopState, Int64, TLocal, TLocal>)>), Action<(Of <(TLocal>)>))
Parallel Class See Also Send Feedback

Executes a for each operation on a OrderablePartitioner in which iterations may run in parallel.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function ForEach(Of TSource, TLocal) ( _
    source As OrderablePartitioner(Of TSource), _
    parallelOptions As ParallelOptions, _
    localInit As Func(Of TLocal), _
    body As Func(Of TSource, ParallelLoopState, Long, TLocal, TLocal), _
    localFinally As Action(Of TLocal) _
) As ParallelLoopResult
C#
public static ParallelLoopResult ForEach<TSource, TLocal>(
    OrderablePartitioner<TSource> source,
    ParallelOptions parallelOptions,
    Func<TLocal> localInit,
    Func<TSource, ParallelLoopState, long, TLocal, TLocal> body,
    Action<TLocal> localFinally
)

Parameters

source
Type: System.Collections.Concurrent..::.OrderablePartitioner <(Of <(TSource>)>)
The OrderablePartitioner that contains the original data source.
parallelOptions
Type: System.Threading.Tasks..::.ParallelOptions
A ParallelOptions instance that configures the behavior of this operation.
localInit
Type: System..::.Func<(Of <(TLocal>)>)
The function delegate that returns the initial state of the local data for each thread.
body
Type: System..::.Func<(Of <(TSource, ParallelLoopState, Int64, TLocal, TLocal>)>)
The delegate that is invoked once per iteration.
localFinally
Type: System..::.Action<(Of <(TLocal>)>)
The delegate that performs a final action on the local state of each thread.

Type Parameters

TSource
The type of the elements in source.
TLocal
The type of the thread-local data.

Return Value

A ParallelLoopResult structure that contains information on what portion of the loop completed.

Remarks

The Partitioner is used to retrieve the elements to be processed, in place of the original data source. If the current element's index is desired, the source must be an OrderablePartitioner.

The body delegate is invoked once for each element in the source Partitioner. It is provided with the following parameters: the current element, a ParallelLoopState instance that may be used to break out of the loop prematurely, the current element's index (an Int64), and some local state that may be shared amongst iterations that execute on the same thread.

The localInit delegate is invoked once for each thread that participates in the loop's execution and returns the initial local state for each of those threads. These initial states are passed to the first body invocations on each thread. Then, every subsequent body invocation returns a possibly modified state value that is passed to the next body invocation. Finally, the last body invocation on each thread returns a state value that is passed to the localFinally delegate. The localFinally delegate is invoked once per thread to perform a final action on each thread's local state.

Exceptions

Exception | Condition
System..::.ArgumentNullException | The exception that is thrown when the source argument is null.
System..::.ArgumentNullException | The exception that is thrown when the parallelOptions argument is null.
System..::.ArgumentNullException | The exception that is thrown when the body argument is null.
System..::.ArgumentNullException | The exception that is thrown when the localInit argument is null.
System..::.ArgumentNullException | The exception that is thrown when the localFinally argument is null.
System..::.OperationCanceledException | The exception that is thrown when the CancellationToken in the parallelOptions argument is set
System..::.InvalidOperationException | The exception that is thrown when the SupportsDynamicPartitions property in the source OrderablePartitioner returns false.
System..::.InvalidOperationException | The exception that is thrown when the KeysNormalized property in the source OrderablePartitioner returns false.
System..::.InvalidOperationException | The exception that is thrown when any methods in the source OrderablePartitioner return null.
System..::.InvalidOperationException | The exception that is thrown when the GetPartitions() or GetOrderablePartitions() methods in the source OrderablePartitioner do not return the correct number of partitions.
System..::.InvalidOperationException | The exception that is thrown when the GetPartitions() or GetOrderablePartitions() methods in the source OrderablePartitioner return an IList with at least one null value.
System..::.InvalidOperationException | The exception that is thrown when the GetDynamicPartitions() or GetDynamicOrderablePartitions() methods in the source OrderablePartitioner return an IEnumerable whose GetEnumerator() method returns null.
System..::.AggregateException | The exception that is thrown to contain an exception thrown from one of the specified delegates.
System..::.ObjectDisposedException | The exception that is thrown when the the CancellationTokenSource associated with the the CancellationToken in the parallelOptions has been disposed.

See Also

Parallel Class
ForEach Overload
System.Threading.Tasks Namespace


ForEach(TSource, TLocal) Method (Partitioner(TSource), ParallelOptions, Func(TLocal), Func(TSource, ParallelLoopState, TLocal, TLocal), Action(TLocal))

[image]

.NET Framework Class Library
Parallel..::.ForEach<(Of <(TSource, TLocal>)>) Method (Partitioner<(Of <(TSource>)>), ParallelOptions, Func<(Of <(TLocal>)>), Func<(Of <(TSource, ParallelLoopState, TLocal, TLocal>)>), Action<(Of <(TLocal>)>))
Parallel Class See Also Send Feedback

Executes a for each operation on a Partitioner in which iterations may run in parallel.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function ForEach(Of TSource, TLocal) ( _
    source As Partitioner(Of TSource), _
    parallelOptions As ParallelOptions, _
    localInit As Func(Of TLocal), _
    body As Func(Of TSource, ParallelLoopState, TLocal, TLocal), _
    localFinally As Action(Of TLocal) _
) As ParallelLoopResult
C#
public static ParallelLoopResult ForEach<TSource, TLocal>(
    Partitioner<TSource> source,
    ParallelOptions parallelOptions,
    Func<TLocal> localInit,
    Func<TSource, ParallelLoopState, TLocal, TLocal> body,
    Action<TLocal> localFinally
)

Parameters

source
Type: System.Collections.Concurrent..::.Partitioner <(Of <(TSource>)>)
The Partitioner that contains the original data source.
parallelOptions
Type: System.Threading.Tasks..::.ParallelOptions
A ParallelOptions instance that configures the behavior of this operation.
localInit
Type: System..::.Func<(Of <(TLocal>)>)
The function delegate that returns the initial state of the local data for each thread.
body
Type: System..::.Func<(Of <(TSource, ParallelLoopState, TLocal, TLocal>)>)
The delegate that is invoked once per iteration.
localFinally
Type: System..::.Action<(Of <(TLocal>)>)
The delegate that performs a final action on the local state of each thread.

Type Parameters

TSource
The type of the elements in source.
TLocal
The type of the thread-local data.

Return Value

A ParallelLoopResult structure that contains information on what portion of the loop completed.

Remarks

The Partitioner is used to retrieve the elements to be processed, in place of the original data source. If the current element's index is desired, the source must be an OrderablePartitioner.

The body delegate is invoked once for each element in the source Partitioner. It is provided with the following parameters: the current element, a ParallelLoopState instance that may be used to break out of the loop prematurely, and some local state that may be shared amongst iterations that execute on the same thread.

The localInit delegate is invoked once for each thread that participates in the loop's execution and returns the initial local state for each of those threads. These initial states are passed to the first body invocations on each thread. Then, every subsequent body invocation returns a possibly modified state value that is passed to the next body invocation. Finally, the last body invocation on each thread returns a state value that is passed to the localFinally delegate. The localFinally delegate is invoked once per thread to perform a final action on each thread's local state.

Exceptions

Exception | Condition
System..::.ArgumentNullException | The exception that is thrown when the source argument is null.
System..::.ArgumentNullException | The exception that is thrown when the parallelOptions argument is null.
System..::.ArgumentNullException | The exception that is thrown when the body argument is null.
System..::.ArgumentNullException | The exception that is thrown when the localInit argument is null.
System..::.ArgumentNullException | The exception that is thrown when the localFinally argument is null.
System..::.OperationCanceledException | The exception that is thrown when the CancellationToken in the parallelOptions argument is set
System..::.InvalidOperationException | The exception that is thrown when the SupportsDynamicPartitions property in the source Partitioner returns false.
System..::.InvalidOperationException | The exception that is thrown when any methods in the source Partitioner return null.
System..::.InvalidOperationException | The exception that is thrown when the GetPartitions() method in the source Partitioner does not return the correct number of partitions.
System..::.InvalidOperationException | The exception that is thrown when the GetPartitions() method in the source Partitioner returns an IList with at least one null value.
System..::.InvalidOperationException | The exception that is thrown when the GetDynamicPartitions() method in the source Partitioner returns an IEnumerable whose GetEnumerator() method returns null.
System..::.AggregateException | The exception that is thrown to contain an exception thrown from one of the specified delegates.
System..::.ObjectDisposedException | The exception that is thrown when the the CancellationTokenSource associated with the the CancellationToken in the parallelOptions has been disposed.

See Also

Parallel Class
ForEach Overload
System.Threading.Tasks Namespace


ForEach(TSource, TLocal) Method (IEnumerable(TSource), ParallelOptions, Func(TLocal), Func(TSource, ParallelLoopState, TLocal, TLocal), Action(TLocal))

[image]

.NET Framework Class Library
Parallel..::.ForEach<(Of <(TSource, TLocal>)>) Method (IEnumerable<(Of <(TSource>)>), ParallelOptions, Func<(Of <(TLocal>)>), Func<(Of <(TSource, ParallelLoopState, TLocal, TLocal>)>), Action<(Of <(TLocal>)>))
Parallel Class See Also Send Feedback

Executes a for each operation on an IEnumerable<(Of <(TSource>)>) in which iterations may run in parallel.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function ForEach(Of TSource, TLocal) ( _
    source As IEnumerable(Of TSource), _
    parallelOptions As ParallelOptions, _
    localInit As Func(Of TLocal), _
    body As Func(Of TSource, ParallelLoopState, TLocal, TLocal), _
    localFinally As Action(Of TLocal) _
) As ParallelLoopResult
C#
public static ParallelLoopResult ForEach<TSource, TLocal>(
    IEnumerable<TSource> source,
    ParallelOptions parallelOptions,
    Func<TLocal> localInit,
    Func<TSource, ParallelLoopState, TLocal, TLocal> body,
    Action<TLocal> localFinally
)

Parameters

source
Type: System.Collections.Generic..::.IEnumerable<(Of <(TSource>)>)
An enumerable data source.
parallelOptions
Type: System.Threading.Tasks..::.ParallelOptions
A ParallelOptions instance that configures the behavior of this operation.
localInit
Type: System..::.Func<(Of <(TLocal>)>)
The function delegate that returns the initial state of the local data for each thread.
body
Type: System..::.Func<(Of <(TSource, ParallelLoopState, TLocal, TLocal>)>)
The delegate that is invoked once per iteration.
localFinally
Type: System..::.Action<(Of <(TLocal>)>)
The delegate that performs a final action on the local state of each thread.

Type Parameters

TSource
The type of the data in the source.
TLocal
The type of the thread-local data.

Return Value

A ParallelLoopResult structure that contains information on what portion of the loop completed.

Remarks

The body delegate is invoked once for each element in the source enumerable. It is provided with the following parameters: the current element, a ParallelLoopState instance that may be used to break out of the loop prematurely, and some local state that may be shared amongst iterations that execute on the same thread.

The localInit delegate is invoked once for each thread that participates in the loop's execution and returns the initial local state for each of those threads. These initial states are passed to the first body invocations on each thread. Then, every subsequent body invocation returns a possibly modified state value that is passed to the next body invocation. Finally, the last body invocation on each thread returns a state value that is passed to the localFinally delegate. The localFinally delegate is invoked once per thread to perform a final action on each thread's local state.

Exceptions

Exception | Condition
System..::.ArgumentNullException | The exception that is thrown when the source argument is null.
System..::.ArgumentNullException | The exception that is thrown when the parallelOptions argument is null.
System..::.ArgumentNullException | The exception that is thrown when the body argument is null.
System..::.ArgumentNullException | The exception that is thrown when the localInit argument is null.
System..::.ArgumentNullException | The exception that is thrown when the localFinally argument is null.
System..::.OperationCanceledException | The exception that is thrown when the CancellationToken in the parallelOptions argument is set
System..::.AggregateException | The exception that is thrown to contain an exception thrown from one of the specified delegates.
System..::.ObjectDisposedException | The exception that is thrown when the the CancellationTokenSource associated with the the CancellationToken in the parallelOptions has been disposed.

See Also

Parallel Class
ForEach Overload
System.Threading.Tasks Namespace


ForEach(TSource, TLocal) Method (IEnumerable(TSource), ParallelOptions, Func(TLocal), Func(TSource, ParallelLoopState, Int64, TLocal, TLocal), Action(TLocal))

[image]

.NET Framework Class Library
Parallel..::.ForEach<(Of <(TSource, TLocal>)>) Method (IEnumerable<(Of <(TSource>)>), ParallelOptions, Func<(Of <(TLocal>)>), Func<(Of <(TSource, ParallelLoopState, Int64, TLocal, TLocal>)>), Action<(Of <(TLocal>)>))
Parallel Class See Also Send Feedback

Executes a for each operation on an IEnumerable<(Of <(TSource>)>) in which iterations may run in parallel.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function ForEach(Of TSource, TLocal) ( _
    source As IEnumerable(Of TSource), _
    parallelOptions As ParallelOptions, _
    localInit As Func(Of TLocal), _
    body As Func(Of TSource, ParallelLoopState, Long, TLocal, TLocal), _
    localFinally As Action(Of TLocal) _
) As ParallelLoopResult
C#
public static ParallelLoopResult ForEach<TSource, TLocal>(
    IEnumerable<TSource> source,
    ParallelOptions parallelOptions,
    Func<TLocal> localInit,
    Func<TSource, ParallelLoopState, long, TLocal, TLocal> body,
    Action<TLocal> localFinally
)

Parameters

source
Type: System.Collections.Generic..::.IEnumerable<(Of <(TSource>)>)
An enumerable data source.
parallelOptions
Type: System.Threading.Tasks..::.ParallelOptions
A ParallelOptions instance that configures the behavior of this operation.
localInit
Type: System..::.Func<(Of <(TLocal>)>)
The function delegate that returns the initial state of the local data for each thread.
body
Type: System..::.Func<(Of <(TSource, ParallelLoopState, Int64, TLocal, TLocal>)>)
The delegate that is invoked once per iteration.
localFinally
Type: System..::.Action<(Of <(TLocal>)>)
The delegate that performs a final action on the local state of each thread.

Type Parameters

TSource
The type of the data in the source.
TLocal
The type of the thread-local data.

Return Value

A ParallelLoopResult structure that contains information on what portion of the loop completed.

Remarks

The body delegate is invoked once for each element in the source enumerable. It is provided with the following parameters: the current element, a ParallelLoopState instance that may be used to break out of the loop prematurely, the current element's index (an Int64), and some local state that may be shared amongst iterations that execute on the same thread.

The localInit delegate is invoked once for each thread that participates in the loop's execution and returns the initial local state for each of those threads. These initial states are passed to the first body invocations on each thread. Then, every subsequent body invocation returns a possibly modified state value that is passed to the next body invocation. Finally, the last body invocation on each thread returns a state value that is passed to the localFinally delegate. The localFinally delegate is invoked once per thread to perform a final action on each thread's local state.

Exceptions

Exception | Condition
System..::.ArgumentNullException | The exception that is thrown when the source argument is null.
System..::.ArgumentNullException | The exception that is thrown when the parallelOptions argument is null.
System..::.ArgumentNullException | The exception that is thrown when the body argument is null.
System..::.ArgumentNullException | The exception that is thrown when the localInit argument is null.
System..::.ArgumentNullException | The exception that is thrown when the localFinally argument is null.
System..::.OperationCanceledException | The exception that is thrown when the CancellationToken in the parallelOptions argument is set
System..::.AggregateException | The exception that is thrown to contain an exception thrown from one of the specified delegates.
System..::.ObjectDisposedException | The exception that is thrown when the the CancellationTokenSource associated with the the CancellationToken in the parallelOptions has been disposed.

See Also

Parallel Class
ForEach Overload
System.Threading.Tasks Namespace


Invoke Method

[image] [image]

.NET Framework Class Library
Parallel..::.Invoke Method
Parallel Class See Also Send Feedback

Overload List

Name | Description
Invoke(array<Action>[]()[]) | Executes each of the provided actions, possibly in parallel.
Invoke(ParallelOptions, array<Action>[]()[]) | Executes each of the provided actions, possibly in parallel.

See Also

Parallel Class
System.Threading.Tasks Namespace


Invoke Method (Action[])

[image]

.NET Framework Class Library
Parallel..::.Invoke Method (array<Action>[]()[])
Parallel Class See Also Send Feedback

Executes each of the provided actions, possibly in parallel.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Sub Invoke ( _
    ParamArray actions As Action() _
)
C#
public static void Invoke(
    params Action[] actions
)

Parameters

actions
Type: array< System..::.Action >[]()[]
An array of Actions to execute.

Remarks

This method can be used to execute a set of operations, potentially in parallel. No guarantees are made about the order in which the operations execute or whether they execute in parallel. This method does not return until each of the provided operations has completed, regardless of whether completion occurs due to normal or exceptional termination.

Exceptions

Exception | Condition
System..::.ArgumentNullException | The exception that is thrown when the actions argument is null.
System..::.ArgumentException | The exception that is thrown when the actions array contains a null element.
System..::.AggregateException | The exception that is thrown when any action in the actions array throws an exception.

See Also

Parallel Class
Invoke Overload
System.Threading.Tasks Namespace


Invoke Method (ParallelOptions, Action[])

[image]

.NET Framework Class Library
Parallel..::.Invoke Method (ParallelOptions, array<Action>[]()[])
Parallel Class See Also Send Feedback

Executes each of the provided actions, possibly in parallel.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Sub Invoke ( _
    parallelOptions As ParallelOptions, _
    ParamArray actions As Action() _
)
C#
public static void Invoke(
    ParallelOptions parallelOptions,
    params Action[] actions
)

Parameters

parallelOptions
Type: System.Threading.Tasks..::.ParallelOptions
A ParallelOptions instance that configures the behavior of this operation.
actions
Type: array< System..::.Action >[]()[]
An array of Actions to execute.

Remarks

This method can be used to execute a set of operations, potentially in parallel. No guarantees are made about the order in which the operations execute or whether the they execute in parallel. This method does not return until each of the provided operations has completed, regardless of whether completion occurs due to normal or exceptional termination.

Exceptions

Exception | Condition
System..::.ArgumentNullException | The exception that is thrown when the actions argument is null.
System..::.ArgumentNullException | The exception that is thrown when the parallelOptions argument is null.
System..::.ArgumentException | The exception that is thrown when the actions array contains a null element.
System..::.OperationCanceledException | The exception that is thrown when the CancellationToken in the parallelOptions is set.
System..::.AggregateException | The exception that is thrown when any action in the actions array throws an exception.
System..::.ObjectDisposedException | The exception that is thrown when the the CancellationTokenSource associated with the the CancellationToken in the parallelOptions has been disposed.

See Also

Parallel Class
Invoke Overload
System.Threading.Tasks Namespace


ParallelLoopResult Structure

[image]

.NET Framework Class Library
ParallelLoopResult Structure
See Also Send Feedback

Provides completion status on the execution of a Parallel loop.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Structure ParallelLoopResult
C#
public struct ParallelLoopResult

Remarks

If IsCompleted returns true, then the loop ran to completion, such that all iterations of the loop were executed. If IsCompleted returns false and LowestBreakIteration returns null, a call to Stop()()() was used to end the loop prematurely. If IsCompleted returns false and LowestBreakIteration returns a non-null integral value, Break()()() was used to end the loop prematurely.

See Also

System.Threading.Tasks Namespace


ParallelLoopResult Methods

[image] [image]

.NET Framework Class Library
ParallelLoopResult Methods
ParallelLoopResult Structure See Also Send Feedback

The ParallelLoopResult type exposes the following members.

Methods

Name | Description
Equals | (Inherited from ValueType.)
Finalize | (Inherited from Object.)
GetHashCode | (Inherited from ValueType.)
GetType | (Inherited from Object.)
MemberwiseClone | (Inherited from Object.)
ToString | (Inherited from ValueType.)

See Also

ParallelLoopResult Structure
System.Threading.Tasks Namespace


ParallelLoopResult Properties

[image] [image]

.NET Framework Class Library
ParallelLoopResult Properties
ParallelLoopResult Structure See Also Send Feedback

The ParallelLoopResult type exposes the following members.

Properties

Name | Description
IsCompleted | Gets whether the loop ran to completion, such that all iterations of the loop were executed and the loop didn't receive a request to end prematurely.
LowestBreakIteration | Gets the index of the lowest iteration from which Break()()() was called.

See Also

ParallelLoopResult Structure
System.Threading.Tasks Namespace


IsCompleted Property

[image]

.NET Framework Class Library
ParallelLoopResult..::.IsCompleted Property
ParallelLoopResult Structure See Also Send Feedback

Gets whether the loop ran to completion, such that all iterations of the loop were executed and the loop didn't receive a request to end prematurely.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public ReadOnly Property IsCompleted As Boolean
C#
public bool IsCompleted { get; }

See Also

ParallelLoopResult Structure
System.Threading.Tasks Namespace


LowestBreakIteration Property

[image]

.NET Framework Class Library
ParallelLoopResult..::.LowestBreakIteration Property
ParallelLoopResult Structure See Also Send Feedback

Gets the index of the lowest iteration from which Break()()() was called.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public ReadOnly Property LowestBreakIteration As Nullable(Of Long)
C#
public Nullable<long> LowestBreakIteration { get; }

Remarks

If Break()()() was not employed, this property will return null.

See Also

ParallelLoopResult Structure
System.Threading.Tasks Namespace


ParallelLoopState Class

[image]

.NET Framework Class Library
ParallelLoopState Class
See Also Send Feedback

Enables iterations of Parallel loops to interact with other iterations.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
<HostProtectionAttribute(SecurityAction.LinkDemand, Synchronization := True,  _
    ExternalThreading := True)> _
Public Class ParallelLoopState
C#
[HostProtectionAttribute(SecurityAction.LinkDemand, Synchronization = true,
    ExternalThreading = true)]
public class ParallelLoopState

Inheritance Hierarchy

System..::.Object
System.Threading.Tasks..::.ParallelLoopState

See Also

System.Threading.Tasks Namespace


ParallelLoopState Methods

[image] [image]

.NET Framework Class Library
ParallelLoopState Methods
ParallelLoopState Class See Also Send Feedback

The ParallelLoopState type exposes the following members.

Methods

Name | Description
Break | Communicates that the Parallel loop should cease execution at the system's earliest convenience of iterations beyond the current iteration.
Equals | (Inherited from Object.)
Finalize | (Inherited from Object.)
GetHashCode | (Inherited from Object.)
GetType | (Inherited from Object.)
MemberwiseClone | (Inherited from Object.)
Stop | Communicates that the Parallel loop should cease execution at the system's earliest convenience.
ToString | (Inherited from Object.)

See Also

ParallelLoopState Class
System.Threading.Tasks Namespace


Break Method

[image]

.NET Framework Class Library
ParallelLoopState..::.Break Method
ParallelLoopState Class See Also Send Feedback

Communicates that the Parallel loop should cease execution at the system's earliest convenience of iterations beyond the current iteration.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Sub Break
C#
public void Break()

Remarks

Break()()() may be used to communicate to the loop that no other iterations after the current iteration need be run. For example, if Break()()() is called from the 100th iteration of a for loop iterating in parallel from 0 to 1000, all iterations less than 100 should still be run, but the iterations from 101 through to 1000 are not necessary.

For long-running iterations that may already be executing, Break()()() causes LowestBreakIteration to be set to the current iteration's index if the current index is less than the current value of LowestBreakIteration.

Break()()() is typically employed in search-based algorithms where an ordering is present in the data source.

Exceptions

Exception | Condition
System..::.InvalidOperationException | The Stop()()() method was previously called. Break()()() and Stop()()() may not be used in combination by iterations of the same loop.

See Also

ParallelLoopState Class
System.Threading.Tasks Namespace


Stop Method

[image]

.NET Framework Class Library
ParallelLoopState..::.Stop Method
ParallelLoopState Class See Also Send Feedback

Communicates that the Parallel loop should cease execution at the system's earliest convenience.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Sub Stop
C#
public void Stop()

Remarks

Stop()()() may be used to communicate to the loop that no other iterations need be run. For long-running iterations that may already be executing, Stop()()() causes IsStopped to return true for all other iterations of the loop, such that another iteration may check IsStopped and exit early if it's observed to be true.

Stop()()() is typically employed in search-based algorithms, where once a result is found, no other iterations need be executed.

Exceptions

Exception | Condition
System..::.InvalidOperationException | The Break()()() method was previously called. Break()()() and Stop()()() may not be used in combination by iterations of the same loop.

See Also

ParallelLoopState Class
System.Threading.Tasks Namespace


ParallelLoopState Properties

[image] [image]

.NET Framework Class Library
ParallelLoopState Properties
ParallelLoopState Class See Also Send Feedback

The ParallelLoopState type exposes the following members.

Properties

Name | Description
IsExceptional | Gets whether any iteration of the loop has thrown an exception that went unhandled by that iteration.
IsStopped | Gets whether any iteration of the loop has called Stop()()().
LowestBreakIteration | Gets the lowest iteration of the loop from which Break()()() was called.
ShouldExitCurrentIteration | Gets whether the current iteration of the loop should exit based on requests made by this or other iterations.

See Also

ParallelLoopState Class
System.Threading.Tasks Namespace


IsExceptional Property

[image]

.NET Framework Class Library
ParallelLoopState..::.IsExceptional Property
ParallelLoopState Class See Also Send Feedback

Gets whether any iteration of the loop has thrown an exception that went unhandled by that iteration.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public ReadOnly Property IsExceptional As Boolean
C#
public bool IsExceptional { get; }

See Also

ParallelLoopState Class
System.Threading.Tasks Namespace


IsStopped Property

[image]

.NET Framework Class Library
ParallelLoopState..::.IsStopped Property
ParallelLoopState Class See Also Send Feedback

Gets whether any iteration of the loop has called Stop()()().

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public ReadOnly Property IsStopped As Boolean
C#
public bool IsStopped { get; }

See Also

ParallelLoopState Class
System.Threading.Tasks Namespace


LowestBreakIteration Property

[image]

.NET Framework Class Library
ParallelLoopState..::.LowestBreakIteration Property
ParallelLoopState Class See Also Send Feedback

Gets the lowest iteration of the loop from which Break()()() was called.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public ReadOnly Property LowestBreakIteration As Nullable(Of Long)
C#
public Nullable<long> LowestBreakIteration { get; }

Remarks

If no iteration of the loop called Break()()(), this property will return null.

See Also

ParallelLoopState Class
System.Threading.Tasks Namespace


ShouldExitCurrentIteration Property

[image]

.NET Framework Class Library
ParallelLoopState..::.ShouldExitCurrentIteration Property
ParallelLoopState Class See Also Send Feedback

Gets whether the current iteration of the loop should exit based on requests made by this or other iterations.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public ReadOnly Property ShouldExitCurrentIteration As Boolean
C#
public bool ShouldExitCurrentIteration { get; }

Remarks

When an iteration of a loop calls Break()()() or Stop()()(), or when one throws an exception, or when the loop is canceled, the Parallel class will proactively attempt to prohibit additional iterations of the loop from starting execution. However, there may be cases where it is unable to prevent additional iterations from starting. It may also be the case that a long-running iteration has already begun execution. In such cases, iterations may explicitly check the ShouldExitCurrentIteration property and cease execution if the property returns true.

See Also

ParallelLoopState Class
System.Threading.Tasks Namespace


ParallelOptions Class

[image]

.NET Framework Class Library
ParallelOptions Class
See Also Send Feedback

Stores options that configure the operation of methods on the Parallel class.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Class ParallelOptions
C#
public class ParallelOptions

Remarks

By default, methods on the Parallel class attempt to utilize all available processors, are non-cancelable, and target the default TaskScheduler (TaskScheduler.Default). ParallelOptions enables overriding these defaults.

Inheritance Hierarchy

System..::.Object
System.Threading.Tasks..::.ParallelOptions

See Also

System.Threading.Tasks Namespace


ParallelOptions Constructor

[image]

.NET Framework Class Library
ParallelOptions Constructor
ParallelOptions Class See Also Send Feedback

Initializes a new instance of the ParallelOptions class.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Sub New
C#
public ParallelOptions()

Remarks

This constructor initializes the instance with default values. MaxDegreeOfParallelism is initialized to -1, signifying that there is no upper bound set on how much parallelism should be employed. CancellationToken is initialized to a non-cancelable token, and TaskScheduler is initialized to the default scheduler (TaskScheduler.Default). All of these defaults may be overwritten using the property set accessors on the instance.

See Also

ParallelOptions Class
System.Threading.Tasks Namespace


ParallelOptions Methods

[image] [image]

.NET Framework Class Library
ParallelOptions Methods
ParallelOptions Class See Also Send Feedback

The ParallelOptions type exposes the following members.

Methods

Name | Description
Equals | (Inherited from Object.)
Finalize | (Inherited from Object.)
GetHashCode | (Inherited from Object.)
GetType | (Inherited from Object.)
MemberwiseClone | (Inherited from Object.)
ToString | (Inherited from Object.)

See Also

ParallelOptions Class
System.Threading.Tasks Namespace


ParallelOptions Properties

[image] [image]

.NET Framework Class Library
ParallelOptions Properties
ParallelOptions Class See Also Send Feedback

The ParallelOptions type exposes the following members.

Properties

Name | Description
CancellationToken | Gets or sets the CancellationToken associated with this ParallelOptions instance.
MaxDegreeOfParallelism | Gets or sets the maximum degree of parallelism enabled by this ParallelOptions instance.
TaskScheduler | Gets or sets the TaskScheduler associated with this ParallelOptions instance. Setting this property to null indicates that the current scheduler should be used.

See Also

ParallelOptions Class
System.Threading.Tasks Namespace


CancellationToken Property

[image]

.NET Framework Class Library
ParallelOptions..::.CancellationToken Property
ParallelOptions Class See Also Send Feedback

Gets or sets the CancellationToken associated with this ParallelOptions instance.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Property CancellationToken As CancellationToken
C#
public CancellationToken CancellationToken { get; set; }

Remarks

Providing a CancellationToken to a Parallel method enables the operation to be exited early. Code external to the operation may cancel the token, and if the operation observes the token being set, it may exit early by throwing an OperationCanceledException.

See Also

ParallelOptions Class
System.Threading.Tasks Namespace


MaxDegreeOfParallelism Property

[image]

.NET Framework Class Library
ParallelOptions..::.MaxDegreeOfParallelism Property
ParallelOptions Class See Also Send Feedback

Gets or sets the maximum degree of parallelism enabled by this ParallelOptions instance.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Property MaxDegreeOfParallelism As Integer
C#
public int MaxDegreeOfParallelism { get; set; }

Remarks

The MaxDegreeOfParallelism limits the number of concurrent operations run by Parallel method calls that are passed this ParallelOptions instance to the set value, if it is positive. If MaxDegreeOfParallelism is -1, then there is no limit placed on the number of concurrently running operations.

Exceptions

Exception | Condition
System..::.ArgumentOutOfRangeException | The exception that is thrown when this MaxDegreeOfParallelism is set to 0 or some value less than -1.

See Also

ParallelOptions Class
System.Threading.Tasks Namespace


TaskScheduler Property

[image]

.NET Framework Class Library
ParallelOptions..::.TaskScheduler Property
ParallelOptions Class See Also Send Feedback

Gets or sets the TaskScheduler associated with this ParallelOptions instance. Setting this property to null indicates that the current scheduler should be used.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Property TaskScheduler As TaskScheduler
C#
public TaskScheduler TaskScheduler { get; set; }

See Also

ParallelOptions Class
System.Threading.Tasks Namespace


Task Class

[image]

.NET Framework Class Library
Task Class
See Also Send Feedback

Represents an asynchronous operation.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
<HostProtectionAttribute(SecurityAction.LinkDemand, Synchronization := True,  _
    ExternalThreading := True)> _
Public Class Task _
    Implements IAsyncResult, IDisposable
C#
[HostProtectionAttribute(SecurityAction.LinkDemand, Synchronization = true,
    ExternalThreading = true)]
public class Task : IAsyncResult, IDisposable

Remarks

Task instances may be created in a variety of ways. The most common approach is by using the Task type's Factory property to retrieve a TaskFactory instance that can be used to create tasks for several purposes. For example, to create a Task that runs an action, the factory's StartNew method may be used:

Copy Code
            // C#
            var t = Task.Factory.StartNew(() => DoAction());

            ' Visual Basic
            Dim t = Task.Factory.StartNew(Function() DoAction())

The Task class also provides constructors that initialize the Task but that do not schedule it for execution. For performance reasons, TaskFactory's StartNew method should be the preferred mechanism for creating and scheduling computational tasks, but for scenarios where creation and scheduling must be separated, the constructors may be used, and the task's Start()()() method may then be used to schedule the task for execution at a later time.

All members of Task, except for Dispose()()(), are thread-safe and may be used from multiple threads concurrently.

For operations that return values, the Task<(Of <(TResult>)>) class should be used.

For developers implementing custom debuggers, several internal and private members of Task may be useful (these may change from release to release). The Int32 m_taskId field serves as the backing store for the Id property, however accessing this field directly from a debugger may be more efficient than accessing the same value through the property's getter method (the s_taskIdCounter Int32 counter is used to retrieve the next available ID for a Task). Similarly, the Int32 m_stateFlags field stores information about the current lifecycle stage of the Task, information also accessible through the Status property. The m_action System.Object field stores a reference to the Task's delegate, and the m_stateObject System.Object field stores the async state passed to the Task by the developer. Finally, for debuggers that parse stack frames, the InternalWait method serves a potential marker for when a Task is entering a wait operation.

Inheritance Hierarchy

System..::.Object
System.Threading.Tasks..::.Task
System.Threading.Tasks..::.Task<(Of <(TResult>)>)

See Also

System.Threading.Tasks Namespace


Task Constructor

[image] [image]

.NET Framework Class Library
Task Constructor
Task Class See Also Send Feedback

Overload List

Name | Description
Task(Action) | Initializes a new Task with the specified action.
Task(Action, CancellationToken) | Initializes a new Task with the specified action and CancellationToken.
Task(Action, TaskCreationOptions) | Initializes a new Task with the specified action and creation options.
Task(Action<(Of <(Object>)>), Object) | Initializes a new Task with the specified action and state.
Task(Action, CancellationToken, TaskCreationOptions) | Initializes a new Task with the specified action and creation options.
Task(Action<(Of <(Object>)>), Object, CancellationToken) | Initializes a new Task with the specified action, state, snd options.
Task(Action<(Of <(Object>)>), Object, TaskCreationOptions) | Initializes a new Task with the specified action, state, snd options.
Task(Action<(Of <(Object>)>), Object, CancellationToken, TaskCreationOptions) | Initializes a new Task with the specified action, state, snd options.

See Also

Task Class
System.Threading.Tasks Namespace


Task Constructor (Action)

[image]

.NET Framework Class Library
Task Constructor (Action)
Task Class See Also Send Feedback

Initializes a new Task with the specified action.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Sub New ( _
    action As Action _
)
C#
public Task(
    Action action
)

Parameters

action
Type: System..::.Action
The delegate that represents the code to execute in the Task.

Exceptions

Exception | Condition
System..::.ArgumentNullException | The action argument is null.

See Also

Task Class
Task Overload
System.Threading.Tasks Namespace


Task Constructor (Action, CancellationToken)

[image]

.NET Framework Class Library
Task Constructor (Action, CancellationToken)
Task Class See Also Send Feedback

Initializes a new Task with the specified action and CancellationToken.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Sub New ( _
    action As Action, _
    cancellationToken As CancellationToken _
)
C#
public Task(
    Action action,
    CancellationToken cancellationToken
)

Parameters

action
Type: System..::.Action
The delegate that represents the code to execute in the Task.
cancellationToken
Type: System.Threading..::.CancellationToken
The CancellationToken that will be assigned to the new Task.

Exceptions

Exception | Condition
System..::.ArgumentNullException | The action argument is null.
System..::.ObjectDisposedException | The provided CancellationToken has already been disposed.

See Also

Task Class
Task Overload
System.Threading.Tasks Namespace


Task Constructor (Action, TaskCreationOptions)

[image]

.NET Framework Class Library
Task Constructor (Action, TaskCreationOptions)
Task Class See Also Send Feedback

Initializes a new Task with the specified action and creation options.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Sub New ( _
    action As Action, _
    creationOptions As TaskCreationOptions _
)
C#
public Task(
    Action action,
    TaskCreationOptions creationOptions
)

Parameters

action
Type: System..::.Action
The delegate that represents the code to execute in the task.
creationOptions
Type: System.Threading.Tasks..::.TaskCreationOptions
The TaskCreationOptions used to customize the Task's behavior.

Exceptions

Exception | Condition
System..::.ArgumentNullException | The action argument is null.
System..::.ArgumentOutOfRangeException | The creationOptions argument specifies an invalid value for TaskCreationOptions.

See Also

Task Class
Task Overload
System.Threading.Tasks Namespace


Task Constructor (Action(Object), Object)

[image]

.NET Framework Class Library
Task Constructor (Action<(Of <(Object>)>), Object)
Task Class See Also Send Feedback

Initializes a new Task with the specified action and state.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Sub New ( _
    action As Action(Of Object), _
    state As Object _
)
C#
public Task(
    Action<Object> action,
    Object state
)

Parameters

action
Type: System..::.Action<(Of <(Object>)>)
The delegate that represents the code to execute in the task.
state
Type: System..::.Object
An object representing data to be used by the action.

Exceptions

Exception | Condition
System..::.ArgumentNullException | The action argument is null.

See Also

Task Class
Task Overload
System.Threading.Tasks Namespace


Task Constructor (Action, CancellationToken, TaskCreationOptions)

[image]

.NET Framework Class Library
Task Constructor (Action, CancellationToken, TaskCreationOptions)
Task Class See Also Send Feedback

Initializes a new Task with the specified action and creation options.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Sub New ( _
    action As Action, _
    cancellationToken As CancellationToken, _
    creationOptions As TaskCreationOptions _
)
C#
public Task(
    Action action,
    CancellationToken cancellationToken,
    TaskCreationOptions creationOptions
)

Parameters

action
Type: System..::.Action
The delegate that represents the code to execute in the task.
cancellationToken
Type: System.Threading..::.CancellationToken
The CancellationToken()()() that will be assigned to the new task.
creationOptions
Type: System.Threading.Tasks..::.TaskCreationOptions
The TaskCreationOptions used to customize the Task's behavior.

Exceptions

Exception | Condition
System..::.ArgumentNullException | The action argument is null.
System..::.ArgumentOutOfRangeException | The creationOptions argument specifies an invalid value for TaskCreationOptions.
System..::.ObjectDisposedException | The provided CancellationToken has already been disposed.

See Also

Task Class
Task Overload
System.Threading.Tasks Namespace


Task Constructor (Action(Object), Object, CancellationToken)

[image]

.NET Framework Class Library
Task Constructor (Action<(Of <(Object>)>), Object, CancellationToken)
Task Class See Also Send Feedback

Initializes a new Task with the specified action, state, snd options.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Sub New ( _
    action As Action(Of Object), _
    state As Object, _
    cancellationToken As CancellationToken _
)
C#
public Task(
    Action<Object> action,
    Object state,
    CancellationToken cancellationToken
)

Parameters

action
Type: System..::.Action<(Of <(Object>)>)
The delegate that represents the code to execute in the task.
state
Type: System..::.Object
An object representing data to be used by the action.
cancellationToken
Type: System.Threading..::.CancellationToken
The CancellationToken()()() that will be assigned to the new task.

Exceptions

Exception | Condition
System..::.ArgumentNullException | The action argument is null.
System..::.ObjectDisposedException | The provided CancellationToken has already been disposed.

See Also

Task Class
Task Overload
System.Threading.Tasks Namespace


Task Constructor (Action(Object), Object, TaskCreationOptions)

[image]

.NET Framework Class Library
Task Constructor (Action<(Of <(Object>)>), Object, TaskCreationOptions)
Task Class See Also Send Feedback

Initializes a new Task with the specified action, state, snd options.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Sub New ( _
    action As Action(Of Object), _
    state As Object, _
    creationOptions As TaskCreationOptions _
)
C#
public Task(
    Action<Object> action,
    Object state,
    TaskCreationOptions creationOptions
)

Parameters

action
Type: System..::.Action<(Of <(Object>)>)
The delegate that represents the code to execute in the task.
state
Type: System..::.Object
An object representing data to be used by the action.
creationOptions
Type: System.Threading.Tasks..::.TaskCreationOptions
The TaskCreationOptions used to customize the Task's behavior.

Exceptions

Exception | Condition
System..::.ArgumentNullException | The action argument is null.
System..::.ArgumentOutOfRangeException | The creationOptions argument specifies an invalid value for TaskCreationOptions.

See Also

Task Class
Task Overload
System.Threading.Tasks Namespace


Task Constructor (Action(Object), Object, CancellationToken, TaskCreationOptions)

[image]

.NET Framework Class Library
Task Constructor (Action<(Of <(Object>)>), Object, CancellationToken, TaskCreationOptions)
Task Class See Also Send Feedback

Initializes a new Task with the specified action, state, snd options.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Sub New ( _
    action As Action(Of Object), _
    state As Object, _
    cancellationToken As CancellationToken, _
    creationOptions As TaskCreationOptions _
)
C#
public Task(
    Action<Object> action,
    Object state,
    CancellationToken cancellationToken,
    TaskCreationOptions creationOptions
)

Parameters

action
Type: System..::.Action<(Of <(Object>)>)
The delegate that represents the code to execute in the task.
state
Type: System..::.Object
An object representing data to be used by the action.
cancellationToken
Type: System.Threading..::.CancellationToken
The CancellationToken()()() that will be assigned to the new task.
creationOptions
Type: System.Threading.Tasks..::.TaskCreationOptions
The TaskCreationOptions used to customize the Task's behavior.

Exceptions

Exception | Condition
System..::.ArgumentNullException | The action argument is null.
System..::.ArgumentOutOfRangeException | The creationOptions argument specifies an invalid value for TaskCreationOptions.
System..::.ObjectDisposedException | The provided CancellationToken has already been disposed.

See Also

Task Class
Task Overload
System.Threading.Tasks Namespace


Task Methods

[image] [image]

.NET Framework Class Library
Task Methods
Task Class See Also Send Feedback

The Task type exposes the following members.

Methods

Name | Description
ContinueWith | Overloaded.
Dispose | Overloaded.
Equals | (Inherited from Object.)
Finalize | (Inherited from Object.)
GetHashCode | (Inherited from Object.)
GetType | (Inherited from Object.)
MemberwiseClone | (Inherited from Object.)
RunSynchronously | Overloaded.
Start | Overloaded.
ToString | (Inherited from Object.)
Wait | Overloaded.
WaitAll | Overloaded.
WaitAny | Overloaded.

See Also

Task Class
System.Threading.Tasks Namespace


ContinueWith Method

[image] [image]

.NET Framework Class Library
Task..::.ContinueWith Method
Task Class See Also Send Feedback

Overload List

Name | Description
ContinueWith(Action<(Of <(Task>)>)) | Creates a continuation that executes when the target Task completes.
ContinueWith<(Of <(TResult>)>)(Func<(Of <(Task, TResult>)>)) | Creates a continuation that executes when the target Task completes.
ContinueWith(Action<(Of <(Task>)>), CancellationToken) | Creates a continuation that executes when the target Task completes.
ContinueWith(Action<(Of <(Task>)>), TaskContinuationOptions) | Creates a continuation that executes when the target Task completes.
ContinueWith(Action<(Of <(Task>)>), TaskScheduler) | Creates a continuation that executes when the target Task completes.
ContinueWith<(Of <(TResult>)>)(Func<(Of <(Task, TResult>)>), CancellationToken) | Creates a continuation that executes when the target Task completes.
ContinueWith<(Of <(TResult>)>)(Func<(Of <(Task, TResult>)>), TaskContinuationOptions) | Creates a continuation that executes when the target Task completes.
ContinueWith<(Of <(TResult>)>)(Func<(Of <(Task, TResult>)>), TaskScheduler) | Creates a continuation that executes when the target Task completes.
ContinueWith(Action<(Of <(Task>)>), CancellationToken, TaskContinuationOptions, TaskScheduler) | Creates a continuation that executes when the target Task completes.
ContinueWith<(Of <(TResult>)>)(Func<(Of <(Task, TResult>)>), CancellationToken, TaskContinuationOptions, TaskScheduler) | Creates a continuation that executes when the target Task completes.

See Also

Task Class
System.Threading.Tasks Namespace


ContinueWith Method (Action(Task))

[image]

.NET Framework Class Library
Task..::.ContinueWith Method (Action<(Of <(Task>)>))
Task Class See Also Send Feedback

Creates a continuation that executes when the target Task completes.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Function ContinueWith ( _
    continuationAction As Action(Of Task) _
) As Task
C#
public Task ContinueWith(
    Action<Task> continuationAction
)

Parameters

continuationAction
Type: System..::.Action<(Of <( Task >)>)
An action to run when the Task completes. When run, the delegate will be passed the completed task as an argument.

Return Value

A new continuation Task.

Remarks

The returned Task will not be scheduled for execution until the current task has completed, whether it completes due to running to completion successfully, faulting due to an unhandled exception, or exiting out early due to being canceled.

Exceptions

Exception | Condition
System..::.ArgumentNullException | The continuationAction argument is null.
System..::.ObjectDisposedException | The Task has been disposed.

See Also

Task Class
ContinueWith Overload
System.Threading.Tasks Namespace


ContinueWith(TResult) Method (Func(Task, TResult))

[image]

.NET Framework Class Library
Task..::.ContinueWith<(Of <(TResult>)>) Method (Func<(Of <(Task, TResult>)>))
Task Class See Also Send Feedback

Creates a continuation that executes when the target Task completes.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Function ContinueWith(Of TResult) ( _
    continuationFunction As Func(Of Task, TResult) _
) As Task(Of TResult)
C#
public Task<TResult> ContinueWith<TResult>(
    Func<Task, TResult> continuationFunction
)

Parameters

continuationFunction
Type: System..::.Func<(Of <( Task, TResult>)>)
A function to run when the Task completes. When run, the delegate will be passed the completed task as an argument.

Type Parameters

TResult
The type of the result produced by the continuation.

Return Value

A new continuation Task<(Of <(TResult>)>).

Remarks

The returned Task<(Of <(TResult>)>) will not be scheduled for execution until the current task has completed, whether it completes due to running to completion successfully, faulting due to an unhandled exception, or exiting out early due to being canceled.

Exceptions

Exception | Condition
System..::.ArgumentNullException | The continuationFunction argument is null.
System..::.ObjectDisposedException | The Task has been disposed.

See Also

Task Class
ContinueWith Overload
System.Threading.Tasks Namespace


ContinueWith Method (Action(Task), CancellationToken)

[image]

.NET Framework Class Library
Task..::.ContinueWith Method (Action<(Of <(Task>)>), CancellationToken)
Task Class See Also Send Feedback

Creates a continuation that executes when the target Task completes.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Function ContinueWith ( _
    continuationAction As Action(Of Task), _
    cancellationToken As CancellationToken _
) As Task
C#
public Task ContinueWith(
    Action<Task> continuationAction,
    CancellationToken cancellationToken
)

Parameters

continuationAction
Type: System..::.Action<(Of <( Task >)>)
An action to run when the Task completes. When run, the delegate will be passed the completed task as an argument.
cancellationToken
Type: System.Threading..::.CancellationToken
The CancellationToken()()() that will be assigned to the new continuation task.

Return Value

A new continuation Task.

Remarks

The returned Task will not be scheduled for execution until the current task has completed, whether it completes due to running to completion successfully, faulting due to an unhandled exception, or exiting out early due to being canceled.

Exceptions

Exception | Condition
System..::.ArgumentNullException | The continuationAction argument is null.
System..::.ObjectDisposedException | The Task has been disposed.
System..::.ObjectDisposedException | The provided CancellationToken has already been disposed.

See Also

Task Class
ContinueWith Overload
System.Threading.Tasks Namespace


ContinueWith Method (Action(Task), TaskContinuationOptions)

[image]

.NET Framework Class Library
Task..::.ContinueWith Method (Action<(Of <(Task>)>), TaskContinuationOptions)
Task Class See Also Send Feedback

Creates a continuation that executes when the target Task completes.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Function ContinueWith ( _
    continuationAction As Action(Of Task), _
    continuationOptions As TaskContinuationOptions _
) As Task
C#
public Task ContinueWith(
    Action<Task> continuationAction,
    TaskContinuationOptions continuationOptions
)

Parameters

continuationAction
Type: System..::.Action<(Of <( Task >)>)
An action to run when the Task completes. When run, the delegate will be passed the completed task as an argument.
continuationOptions
Type: System.Threading.Tasks..::.TaskContinuationOptions
Options for when the continuation is scheduled and how it behaves. This includes criteria, such as OnlyOnCanceled, as well as execution options, such as ExecuteSynchronously.

Return Value

A new continuation Task.

Remarks

The returned Task will not be scheduled for execution until the current task has completed. If the continuation criteria specified through the continuationOptions parameter are not met, the continuation task will be canceled instead of scheduled.

Exceptions

Exception | Condition
System..::.ArgumentNullException | The continuationAction argument is null.
System..::.ArgumentOutOfRangeException | The continuationOptions argument specifies an invalid value for TaskContinuationOptions.
System..::.ObjectDisposedException | The Task has been disposed.

See Also

Task Class
ContinueWith Overload
System.Threading.Tasks Namespace


ContinueWith Method (Action(Task), TaskScheduler)

[image]

.NET Framework Class Library
Task..::.ContinueWith Method (Action<(Of <(Task>)>), TaskScheduler)
Task Class See Also Send Feedback

Creates a continuation that executes when the target Task completes.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Function ContinueWith ( _
    continuationAction As Action(Of Task), _
    scheduler As TaskScheduler _
) As Task
C#
public Task ContinueWith(
    Action<Task> continuationAction,
    TaskScheduler scheduler
)

Parameters

continuationAction
Type: System..::.Action<(Of <( Task >)>)
An action to run when the Task completes. When run, the delegate will be passed the completed task as an argument.
scheduler
Type: System.Threading.Tasks..::.TaskScheduler
The TaskScheduler to associate with the continuation task and to use for its execution.

Return Value

A new continuation Task.

Remarks

The returned Task will not be scheduled for execution until the current task has completed, whether it completes due to running to completion successfully, faulting due to an unhandled exception, or exiting out early due to being canceled.

Exceptions

Exception | Condition
System..::.ArgumentNullException | The continuationAction argument is null.
System..::.ArgumentNullException | The scheduler argument is null.
System..::.ObjectDisposedException | The Task has been disposed.

See Also

Task Class
ContinueWith Overload
System.Threading.Tasks Namespace


ContinueWith(TResult) Method (Func(Task, TResult), CancellationToken)

[image]

.NET Framework Class Library
Task..::.ContinueWith<(Of <(TResult>)>) Method (Func<(Of <(Task, TResult>)>), CancellationToken)
Task Class See Also Send Feedback

Creates a continuation that executes when the target Task completes.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Function ContinueWith(Of TResult) ( _
    continuationFunction As Func(Of Task, TResult), _
    cancellationToken As CancellationToken _
) As Task(Of TResult)
C#
public Task<TResult> ContinueWith<TResult>(
    Func<Task, TResult> continuationFunction,
    CancellationToken cancellationToken
)

Parameters

continuationFunction
Type: System..::.Func<(Of <( Task, TResult>)>)
A function to run when the Task completes. When run, the delegate will be passed the completed task as an argument.
cancellationToken
Type: System.Threading..::.CancellationToken
The CancellationToken()()() that will be assigned to the new continuation task.

Type Parameters

TResult
The type of the result produced by the continuation.

Return Value

A new continuation Task<(Of <(TResult>)>).

Remarks

The returned Task<(Of <(TResult>)>) will not be scheduled for execution until the current task has completed, whether it completes due to running to completion successfully, faulting due to an unhandled exception, or exiting out early due to being canceled.

Exceptions

Exception | Condition
System..::.ArgumentNullException | The continuationFunction argument is null.
System..::.ObjectDisposedException | The Task has been disposed.
System..::.ObjectDisposedException | The provided CancellationToken has already been disposed.

See Also

Task Class
ContinueWith Overload
System.Threading.Tasks Namespace


ContinueWith(TResult) Method (Func(Task, TResult), TaskContinuationOptions)

[image]

.NET Framework Class Library
Task..::.ContinueWith<(Of <(TResult>)>) Method (Func<(Of <(Task, TResult>)>), TaskContinuationOptions)
Task Class See Also Send Feedback

Creates a continuation that executes when the target Task completes.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Function ContinueWith(Of TResult) ( _
    continuationFunction As Func(Of Task, TResult), _
    continuationOptions As TaskContinuationOptions _
) As Task(Of TResult)
C#
public Task<TResult> ContinueWith<TResult>(
    Func<Task, TResult> continuationFunction,
    TaskContinuationOptions continuationOptions
)

Parameters

continuationFunction
Type: System..::.Func<(Of <( Task, TResult>)>)
A function to run when the Task completes. When run, the delegate will be passed the completed task as an argument.
continuationOptions
Type: System.Threading.Tasks..::.TaskContinuationOptions
Options for when the continuation is scheduled and how it behaves. This includes criteria, such as OnlyOnCanceled, as well as execution options, such as ExecuteSynchronously.

Type Parameters

TResult
The type of the result produced by the continuation.

Return Value

A new continuation Task<(Of <(TResult>)>).

Remarks

The returned Task<(Of <(TResult>)>) will not be scheduled for execution until the current task has completed. If the continuation criteria specified through the continuationOptions parameter are not met, the continuation task will be canceled instead of scheduled.

Exceptions

Exception | Condition
System..::.ArgumentNullException | The continuationFunction argument is null.
System..::.ArgumentOutOfRangeException | The continuationOptions argument specifies an invalid value for TaskContinuationOptions.
System..::.ObjectDisposedException | The Task has been disposed.

See Also

Task Class
ContinueWith Overload
System.Threading.Tasks Namespace


ContinueWith(TResult) Method (Func(Task, TResult), TaskScheduler)

[image]

.NET Framework Class Library
Task..::.ContinueWith<(Of <(TResult>)>) Method (Func<(Of <(Task, TResult>)>), TaskScheduler)
Task Class See Also Send Feedback

Creates a continuation that executes when the target Task completes.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Function ContinueWith(Of TResult) ( _
    continuationFunction As Func(Of Task, TResult), _
    scheduler As TaskScheduler _
) As Task(Of TResult)
C#
public Task<TResult> ContinueWith<TResult>(
    Func<Task, TResult> continuationFunction,
    TaskScheduler scheduler
)

Parameters

continuationFunction
Type: System..::.Func<(Of <( Task, TResult>)>)
A function to run when the Task completes. When run, the delegate will be passed the completed task as an argument.
scheduler
Type: System.Threading.Tasks..::.TaskScheduler
The TaskScheduler to associate with the continuation task and to use for its execution.

Type Parameters

TResult
The type of the result produced by the continuation.

Return Value

A new continuation Task<(Of <(TResult>)>).

Remarks

The returned Task<(Of <(TResult>)>) will not be scheduled for execution until the current task has completed, whether it completes due to running to completion successfully, faulting due to an unhandled exception, or exiting out early due to being canceled.

Exceptions

Exception | Condition
System..::.ArgumentNullException | The continuationFunction argument is null.
System..::.ArgumentNullException | The scheduler argument is null.
System..::.ObjectDisposedException | The Task has been disposed.

See Also

Task Class
ContinueWith Overload
System.Threading.Tasks Namespace


ContinueWith Method (Action(Task), CancellationToken, TaskContinuationOptions, TaskScheduler)

[image]

.NET Framework Class Library
Task..::.ContinueWith Method (Action<(Of <(Task>)>), CancellationToken, TaskContinuationOptions, TaskScheduler)
Task Class See Also Send Feedback

Creates a continuation that executes when the target Task completes.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Function ContinueWith ( _
    continuationAction As Action(Of Task), _
    cancellationToken As CancellationToken, _
    continuationOptions As TaskContinuationOptions, _
    scheduler As TaskScheduler _
) As Task
C#
public Task ContinueWith(
    Action<Task> continuationAction,
    CancellationToken cancellationToken,
    TaskContinuationOptions continuationOptions,
    TaskScheduler scheduler
)

Parameters

continuationAction
Type: System..::.Action<(Of <( Task >)>)
An action to run when the Task completes. When run, the delegate will be passed the completed task as an argument.
cancellationToken
Type: System.Threading..::.CancellationToken
The CancellationToken()()() that will be assigned to the new continuation task.
continuationOptions
Type: System.Threading.Tasks..::.TaskContinuationOptions
Options for when the continuation is scheduled and how it behaves. This includes criteria, such as OnlyOnCanceled, as well as execution options, such as ExecuteSynchronously.
scheduler
Type: System.Threading.Tasks..::.TaskScheduler
The TaskScheduler to associate with the continuation task and to use for its execution.

Return Value

A new continuation Task.

Remarks

The returned Task will not be scheduled for execution until the current task has completed. If the criteria specified through the continuationOptions parameter are not met, the continuation task will be canceled instead of scheduled.

Exceptions

Exception | Condition
System..::.ArgumentNullException | The continuationAction argument is null.
System..::.ArgumentOutOfRangeException | The continuationOptions argument specifies an invalid value for TaskContinuationOptions.
System..::.ArgumentNullException | The scheduler argument is null.
System..::.ObjectDisposedException | The Task has been disposed.
System..::.ObjectDisposedException | The provided CancellationToken has already been disposed.

See Also

Task Class
ContinueWith Overload
System.Threading.Tasks Namespace


ContinueWith(TResult) Method (Func(Task, TResult), CancellationToken, TaskContinuationOptions, TaskScheduler)

[image]

.NET Framework Class Library
Task..::.ContinueWith<(Of <(TResult>)>) Method (Func<(Of <(Task, TResult>)>), CancellationToken, TaskContinuationOptions, TaskScheduler)
Task Class See Also Send Feedback

Creates a continuation that executes when the target Task completes.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Function ContinueWith(Of TResult) ( _
    continuationFunction As Func(Of Task, TResult), _
    cancellationToken As CancellationToken, _
    continuationOptions As TaskContinuationOptions, _
    scheduler As TaskScheduler _
) As Task(Of TResult)
C#
public Task<TResult> ContinueWith<TResult>(
    Func<Task, TResult> continuationFunction,
    CancellationToken cancellationToken,
    TaskContinuationOptions continuationOptions,
    TaskScheduler scheduler
)

Parameters

continuationFunction
Type: System..::.Func<(Of <( Task, TResult>)>)
A function to run when the Task completes. When run, the delegate will be passed the completed task as an argument.
cancellationToken
Type: System.Threading..::.CancellationToken
The CancellationToken()()() that will be assigned to the new continuation task.
continuationOptions
Type: System.Threading.Tasks..::.TaskContinuationOptions
Options for when the continuation is scheduled and how it behaves. This includes criteria, such as OnlyOnCanceled, as well as execution options, such as ExecuteSynchronously.
scheduler
Type: System.Threading.Tasks..::.TaskScheduler
The TaskScheduler to associate with the continuation task and to use for its execution.

Type Parameters

TResult
The type of the result produced by the continuation.

Return Value

A new continuation Task<(Of <(TResult>)>).

Remarks

The returned Task<(Of <(TResult>)>) will not be scheduled for execution until the current task has completed. If the criteria specified through the continuationOptions parameter are not met, the continuation task will be canceled instead of scheduled.

Exceptions

Exception | Condition
System..::.ArgumentNullException | The continuationFunction argument is null.
System..::.ArgumentOutOfRangeException | The continuationOptions argument specifies an invalid value for TaskContinuationOptions.
System..::.ArgumentNullException | The scheduler argument is null.
System..::.ObjectDisposedException | The Task has been disposed.
System..::.ObjectDisposedException | The provided CancellationToken has already been disposed.

See Also

Task Class
ContinueWith Overload
System.Threading.Tasks Namespace


Dispose Method

[image] [image]

.NET Framework Class Library
Task..::.Dispose Method
Task Class See Also Send Feedback

Overload List

Name | Description
Dispose()()() | Disposes the Task, releasing all of its unmanaged resources.
Dispose(Boolean) | Disposes the Task, releasing all of its unmanaged resources.

See Also

Task Class
System.Threading.Tasks Namespace


Dispose Method

[image]

.NET Framework Class Library
Task..::.Dispose Method
Task Class See Also Send Feedback

Disposes the Task, releasing all of its unmanaged resources.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Sub Dispose
C#
public void Dispose()

Implements

IDisposable..::.Dispose()()()

Remarks

Unlike most of the members of Task, this method is not thread-safe. Also, Dispose()()() may only be called on a Task that is in one of the final states: RanToCompletion, Faulted, or Canceled.

Exceptions

Exception | Condition
System..::.InvalidOperationException | The exception that is thrown if the Task is not in one of the final states: RanToCompletion, Faulted, or Canceled.

See Also

Task Class
Dispose Overload
System.Threading.Tasks Namespace


Dispose Method (Boolean)

[image]

.NET Framework Class Library
Task..::.Dispose Method (Boolean)
Task Class See Also Send Feedback

Disposes the Task, releasing all of its unmanaged resources.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Protected Overridable Sub Dispose ( _
    disposing As Boolean _
)
C#
protected virtual void Dispose(
    bool disposing
)

Parameters

disposing
Type: System..::.Boolean
A Boolean value that indicates whether this method is being called due to a call to Dispose()()().

Remarks

Unlike most of the members of Task, this method is not thread-safe.

See Also

Task Class
Dispose Overload
System.Threading.Tasks Namespace


RunSynchronously Method

[image] [image]

.NET Framework Class Library
Task..::.RunSynchronously Method
Task Class See Also Send Feedback

Overload List

Name | Description
RunSynchronously()()() | Runs the Task synchronously on the current TaskScheduler.
RunSynchronously(TaskScheduler) | Runs the Task synchronously on the scheduler provided.

See Also

Task Class
System.Threading.Tasks Namespace


RunSynchronously Method

[image]

.NET Framework Class Library
Task..::.RunSynchronously Method
Task Class See Also Send Feedback

Runs the Task synchronously on the current TaskScheduler.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Sub RunSynchronously
C#
public void RunSynchronously()

Remarks

A task may only be started and run only once. Any attempts to schedule a task a second time will result in an exception.

Tasks executed with RunSynchronously()()() will be associated with the current TaskScheduler.

If the target scheduler does not support running this Task on the current thread, the Task will be scheduled for execution on the scheduler, and the current thread will block until the Task has completed execution.

Exceptions

Exception | Condition
System..::.InvalidOperationException | The Task is not in a valid state to be started. It may have already been started, executed, or canceled, or it may have been created in a manner that doesn't support direct scheduling.
System..::.ObjectDisposedException | The Task instance has been disposed.

See Also

Task Class
RunSynchronously Overload
System.Threading.Tasks Namespace


RunSynchronously Method (TaskScheduler)

[image]

.NET Framework Class Library
Task..::.RunSynchronously Method (TaskScheduler)
Task Class See Also Send Feedback

Runs the Task synchronously on the scheduler provided.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Sub RunSynchronously ( _
    scheduler As TaskScheduler _
)
C#
public void RunSynchronously(
    TaskScheduler scheduler
)

Parameters

scheduler
Type: System.Threading.Tasks..::.TaskScheduler
The scheduler on which to attempt to run this task inline.

Remarks

A task may only be started and run only once. Any attempts to schedule a task a second time will result in an exception.

If the target scheduler does not support running this Task on the current thread, the Task will be scheduled for execution on the scheduler, and the current thread will block until the Task has completed execution.

Exceptions

Exception | Condition
System..::.InvalidOperationException | The Task is not in a valid state to be started. It may have already been started, executed, or canceled, or it may have been created in a manner that doesn't support direct scheduling.
System..::.ObjectDisposedException | The Task instance has been disposed.
System..::.ArgumentNullException | The scheduler parameter is null.

See Also

Task Class
RunSynchronously Overload
System.Threading.Tasks Namespace


Start Method

[image] [image]

.NET Framework Class Library
Task..::.Start Method
Task Class See Also Send Feedback

Overload List

Name | Description
Start()()() | Starts the Task, scheduling it for execution to the current TaskScheduler.
Start(TaskScheduler) | Starts the Task, scheduling it for execution to the specified TaskScheduler.

See Also

Task Class
System.Threading.Tasks Namespace


Start Method

[image]

.NET Framework Class Library
Task..::.Start Method
Task Class See Also Send Feedback

Starts the Task, scheduling it for execution to the current TaskScheduler.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Sub Start
C#
public void Start()

Remarks

A task may only be started and run only once. Any attempts to schedule a task a second time will result in an exception.

Exceptions

Exception | Condition
System..::.InvalidOperationException | The Task is not in a valid state to be started. It may have already been started, executed, or canceled, or it may have been created in a manner that doesn't support direct scheduling.
System..::.ObjectDisposedException | The Task instance has been disposed.

See Also

Task Class
Start Overload
System.Threading.Tasks Namespace


Start Method (TaskScheduler)

[image]

.NET Framework Class Library
Task..::.Start Method (TaskScheduler)
Task Class See Also Send Feedback

Starts the Task, scheduling it for execution to the specified TaskScheduler.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Sub Start ( _
    scheduler As TaskScheduler _
)
C#
public void Start(
    TaskScheduler scheduler
)

Parameters

scheduler
Type: System.Threading.Tasks..::.TaskScheduler
The TaskScheduler with which to associate and execute this task.

Remarks

A task may only be started and run only once. Any attempts to schedule a task a second time will result in an exception.

Exceptions

Exception | Condition
System..::.ArgumentNullException | The scheduler argument is null.
System..::.InvalidOperationException | The Task is not in a valid state to be started. It may have already been started, executed, or canceled, or it may have been created in a manner that doesn't support direct scheduling.
System..::.ObjectDisposedException | The Task instance has been disposed.

See Also

Task Class
Start Overload
System.Threading.Tasks Namespace


Wait Method

[image] [image]

.NET Framework Class Library
Task..::.Wait Method
Task Class See Also Send Feedback

Overload List

Name | Description
Wait()()() | Waits for the Task to complete execution.
Wait(Int32) | Waits for the Task to complete execution.
Wait(CancellationToken) | Waits for the Task to complete execution.
Wait(TimeSpan) | Waits for the Task to complete execution.
Wait(Int32, CancellationToken) | Waits for the Task to complete execution.

See Also

Task Class
System.Threading.Tasks Namespace


Wait Method

[image]

.NET Framework Class Library
Task..::.Wait Method
Task Class See Also Send Feedback

Waits for the Task to complete execution.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Sub Wait
C#
public void Wait()

Exceptions

Exception | Condition
System..::.AggregateException | The Task was canceled -or- an exception was thrown during the execution of the Task.
System..::.ObjectDisposedException | The Task has been disposed.

See Also

Task Class
Wait Overload
System.Threading.Tasks Namespace


Wait Method (Int32)

[image]

.NET Framework Class Library
Task..::.Wait Method (Int32)
Task Class See Also Send Feedback

Waits for the Task to complete execution.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Function Wait ( _
    millisecondsTimeout As Integer _
) As Boolean
C#
public bool Wait(
    int millisecondsTimeout
)

Parameters

millisecondsTimeout
Type: System..::.Int32
The number of milliseconds to wait, or Infinite (-1) to wait indefinitely.

Return Value

true if the Task completed execution within the allotted time; otherwise, false.

Exceptions

Exception | Condition
System..::.ArgumentOutOfRangeException | millisecondsTimeout is a negative number other than -1, which represents an infinite time-out.
System..::.AggregateException | The Task was canceled -or- an exception was thrown during the execution of the Task.
System..::.ObjectDisposedException | The Task has been disposed.

See Also

Task Class
Wait Overload
System.Threading.Tasks Namespace


Wait Method (CancellationToken)

[image]

.NET Framework Class Library
Task..::.Wait Method (CancellationToken)
Task Class See Also Send Feedback

Waits for the Task to complete execution.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Sub Wait ( _
    cancellationToken As CancellationToken _
)
C#
public void Wait(
    CancellationToken cancellationToken
)

Parameters

cancellationToken
Type: System.Threading..::.CancellationToken
A CancellationToken()()() to observe while waiting for the task to complete.

Exceptions

Exception | Condition
System..::.OperationCanceledException | The cancellationToken was canceled.
System..::.AggregateException | The Task was canceled -or- an exception was thrown during the execution of the Task.
System..::.ObjectDisposedException | The Task has been disposed.

See Also

Task Class
Wait Overload
System.Threading.Tasks Namespace


Wait Method (TimeSpan)

[image]

.NET Framework Class Library
Task..::.Wait Method (TimeSpan)
Task Class See Also Send Feedback

Waits for the Task to complete execution.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Function Wait ( _
    timeout As TimeSpan _
) As Boolean
C#
public bool Wait(
    TimeSpan timeout
)

Parameters

timeout
Type: System..::.TimeSpan
A TimeSpan that represents the number of milliseconds to wait, or a TimeSpan that represents -1 milliseconds to wait indefinitely.

Return Value

true if the Task completed execution within the allotted time; otherwise, false.

Exceptions

Exception | Condition
System..::.AggregateException | The Task was canceled -or- an exception was thrown during the execution of the Task.
System..::.ArgumentOutOfRangeException | timeout is a negative number other than -1 milliseconds, which represents an infinite time-out -or- timeout is greater than MaxValue.
System..::.ObjectDisposedException | The Task has been disposed.

See Also

Task Class
Wait Overload
System.Threading.Tasks Namespace


Wait Method (Int32, CancellationToken)

[image]

.NET Framework Class Library
Task..::.Wait Method (Int32, CancellationToken)
Task Class See Also Send Feedback

Waits for the Task to complete execution.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Function Wait ( _
    millisecondsTimeout As Integer, _
    cancellationToken As CancellationToken _
) As Boolean
C#
public bool Wait(
    int millisecondsTimeout,
    CancellationToken cancellationToken
)

Parameters

millisecondsTimeout
Type: System..::.Int32
The number of milliseconds to wait, or Infinite (-1) to wait indefinitely.
cancellationToken
Type: System.Threading..::.CancellationToken
A CancellationToken()()() to observe while waiting for the task to complete.

Return Value

true if the Task completed execution within the allotted time; otherwise, false.

Exceptions

Exception | Condition
System..::.AggregateException | The Task was canceled -or- an exception was thrown during the execution of the Task.
System..::.ObjectDisposedException | The Task has been disposed.
System..::.ArgumentOutOfRangeException | millisecondsTimeout is a negative number other than -1, which represents an infinite time-out.
System..::.OperationCanceledException | The cancellationToken was canceled.

See Also

Task Class
Wait Overload
System.Threading.Tasks Namespace


WaitAll Method

[image] [image]

.NET Framework Class Library
Task..::.WaitAll Method
Task Class See Also Send Feedback

Overload List

Name | Description
WaitAll(array<Task>[]()[]) | Waits for all of the provided Task objects to complete execution.
WaitAll(array<Task>[]()[], Int32) | Waits for all of the provided Task objects to complete execution.
WaitAll(array<Task>[]()[], CancellationToken) | Waits for all of the provided Task objects to complete execution.
WaitAll(array<Task>[]()[], TimeSpan) | Waits for all of the provided Task objects to complete execution.
WaitAll(array<Task>[]()[], Int32, CancellationToken) | Waits for all of the provided Task objects to complete execution.

See Also

Task Class
System.Threading.Tasks Namespace


WaitAll Method (Task[])

[image]

.NET Framework Class Library
Task..::.WaitAll Method (array<Task>[]()[])
Task Class See Also Send Feedback

Waits for all of the provided Task objects to complete execution.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Sub WaitAll ( _
    ParamArray tasks As Task() _
)
C#
public static void WaitAll(
    params Task[] tasks
)

Parameters

tasks
Type: array< System.Threading.Tasks..::.Task >[]()[]
An array of Task instances on which to wait.

Exceptions

Exception | Condition
System..::.ArgumentNullException | The tasks argument is null.
System..::.ArgumentNullException | The tasks argument contains a null element.
System..::.AggregateException | At least one of the Task instances was canceled -or- an exception was thrown during the execution of at least one of the Task instances.
System..::.ObjectDisposedException | The Task has been disposed.

See Also

Task Class
WaitAll Overload
System.Threading.Tasks Namespace


WaitAll Method (Task[], Int32)

[image]

.NET Framework Class Library
Task..::.WaitAll Method (array<Task>[]()[], Int32)
Task Class See Also Send Feedback

Waits for all of the provided Task objects to complete execution.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function WaitAll ( _
    tasks As Task(), _
    millisecondsTimeout As Integer _
) As Boolean
C#
public static bool WaitAll(
    Task[] tasks,
    int millisecondsTimeout
)

Parameters

tasks
Type: array< System.Threading.Tasks..::.Task >[]()[]
An array of Task instances on which to wait.
millisecondsTimeout
Type: System..::.Int32
The number of milliseconds to wait, or Infinite (-1) to wait indefinitely.

Return Value

true if all of the Task instances completed execution within the allotted time; otherwise, false.

Exceptions

Exception | Condition
System..::.ArgumentNullException | The tasks argument is null.
System..::.ArgumentException | The tasks argument contains a null element.
System..::.AggregateException | At least one of the Task instances was canceled -or- an exception was thrown during the execution of at least one of the Task instances.
System..::.ObjectDisposedException | The Task has been disposed.
System..::.ArgumentOutOfRangeException | millisecondsTimeout is a negative number other than -1, which represents an infinite time-out.

See Also

Task Class
WaitAll Overload
System.Threading.Tasks Namespace


WaitAll Method (Task[], CancellationToken)

[image]

.NET Framework Class Library
Task..::.WaitAll Method (array<Task>[]()[], CancellationToken)
Task Class See Also Send Feedback

Waits for all of the provided Task objects to complete execution.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Sub WaitAll ( _
    tasks As Task(), _
    cancellationToken As CancellationToken _
)
C#
public static void WaitAll(
    Task[] tasks,
    CancellationToken cancellationToken
)

Parameters

tasks
Type: array< System.Threading.Tasks..::.Task >[]()[]
An array of Task instances on which to wait.
cancellationToken
Type: System.Threading..::.CancellationToken
A CancellationToken()()() to observe while waiting for the tasks to complete.

Return Value

true if all of the Task instances completed execution within the allotted time; otherwise, false.

Exceptions

Exception | Condition
System..::.ArgumentNullException | The tasks argument is null.
System..::.ArgumentException | The tasks argument contains a null element.
System..::.AggregateException | At least one of the Task instances was canceled -or- an exception was thrown during the execution of at least one of the Task instances.
System..::.OperationCanceledException | The cancellationToken was canceled.
System..::.ObjectDisposedException | The Task has been disposed.

See Also

Task Class
WaitAll Overload
System.Threading.Tasks Namespace


WaitAll Method (Task[], TimeSpan)

[image]

.NET Framework Class Library
Task..::.WaitAll Method (array<Task>[]()[], TimeSpan)
Task Class See Also Send Feedback

Waits for all of the provided Task objects to complete execution.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function WaitAll ( _
    tasks As Task(), _
    timeout As TimeSpan _
) As Boolean
C#
public static bool WaitAll(
    Task[] tasks,
    TimeSpan timeout
)

Parameters

tasks
Type: array< System.Threading.Tasks..::.Task >[]()[]
An array of Task instances on which to wait.
timeout
Type: System..::.TimeSpan
A TimeSpan that represents the number of milliseconds to wait, or a TimeSpan that represents -1 milliseconds to wait indefinitely.

Return Value

true if all of the Task instances completed execution within the allotted time; otherwise, false.

Exceptions

Exception | Condition
System..::.ArgumentNullException | The tasks argument is null.
System..::.ArgumentException | The tasks argument contains a null element.
System..::.AggregateException | At least one of the Task instances was canceled -or- an exception was thrown during the execution of at least one of the Task instances.
System..::.ArgumentOutOfRangeException | timeout is a negative number other than -1 milliseconds, which represents an infinite time-out -or- timeout is greater than MaxValue.
System..::.ObjectDisposedException | The Task has been disposed.

See Also

Task Class
WaitAll Overload
System.Threading.Tasks Namespace


WaitAll Method (Task[], Int32, CancellationToken)

[image]

.NET Framework Class Library
Task..::.WaitAll Method (array<Task>[]()[], Int32, CancellationToken)
Task Class See Also Send Feedback

Waits for all of the provided Task objects to complete execution.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function WaitAll ( _
    tasks As Task(), _
    millisecondsTimeout As Integer, _
    cancellationToken As CancellationToken _
) As Boolean
C#
public static bool WaitAll(
    Task[] tasks,
    int millisecondsTimeout,
    CancellationToken cancellationToken
)

Parameters

tasks
Type: array< System.Threading.Tasks..::.Task >[]()[]
An array of Task instances on which to wait.
millisecondsTimeout
Type: System..::.Int32
The number of milliseconds to wait, or Infinite (-1) to wait indefinitely.
cancellationToken
Type: System.Threading..::.CancellationToken
A CancellationToken()()() to observe while waiting for the tasks to complete.

Return Value

true if all of the Task instances completed execution within the allotted time; otherwise, false.

Exceptions

Exception | Condition
System..::.ArgumentNullException | The tasks argument is null.
System..::.ArgumentException | The tasks argument contains a null element.
System..::.AggregateException | At least one of the Task instances was canceled -or- an exception was thrown during the execution of at least one of the Task instances.
System..::.ObjectDisposedException | The Task has been disposed.
System..::.ArgumentOutOfRangeException | millisecondsTimeout is a negative number other than -1, which represents an infinite time-out.
System..::.OperationCanceledException | The cancellationToken was canceled.

See Also

Task Class
WaitAll Overload
System.Threading.Tasks Namespace


WaitAny Method

[image] [image]

.NET Framework Class Library
Task..::.WaitAny Method
Task Class See Also Send Feedback

Overload List

Name | Description
WaitAny(array<Task>[]()[]) | Waits for any of the provided Task objects to complete execution.
WaitAny(array<Task>[]()[], Int32) | Waits for any of the provided Task objects to complete execution.
WaitAny(array<Task>[]()[], CancellationToken) | Waits for any of the provided Task objects to complete execution.
WaitAny(array<Task>[]()[], TimeSpan) | Waits for any of the provided Task objects to complete execution.
WaitAny(array<Task>[]()[], Int32, CancellationToken) | Waits for any of the provided Task objects to complete execution.

See Also

Task Class
System.Threading.Tasks Namespace


WaitAny Method (Task[])

[image]

.NET Framework Class Library
Task..::.WaitAny Method (array<Task>[]()[])
Task Class See Also Send Feedback

Waits for any of the provided Task objects to complete execution.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function WaitAny ( _
    ParamArray tasks As Task() _
) As Integer
C#
public static int WaitAny(
    params Task[] tasks
)

Parameters

tasks
Type: array< System.Threading.Tasks..::.Task >[]()[]
An array of Task instances on which to wait.

Return Value

The index of the completed task in the tasks array argument.

Exceptions

Exception | Condition
System..::.ArgumentNullException | The tasks argument is null.
System..::.ArgumentException | The tasks argument contains a null element.
System..::.ObjectDisposedException | The Task has been disposed.

See Also

Task Class
WaitAny Overload
System.Threading.Tasks Namespace


WaitAny Method (Task[], Int32)

[image]

.NET Framework Class Library
Task..::.WaitAny Method (array<Task>[]()[], Int32)
Task Class See Also Send Feedback

Waits for any of the provided Task objects to complete execution.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function WaitAny ( _
    tasks As Task(), _
    millisecondsTimeout As Integer _
) As Integer
C#
public static int WaitAny(
    Task[] tasks,
    int millisecondsTimeout
)

Parameters

tasks
Type: array< System.Threading.Tasks..::.Task >[]()[]
An array of Task instances on which to wait.
millisecondsTimeout
Type: System..::.Int32
The number of milliseconds to wait, or Infinite (-1) to wait indefinitely.

Return Value

The index of the completed task in the tasks array argument, or -1 if the timeout occurred.

Exceptions

Exception | Condition
System..::.ArgumentNullException | The tasks argument is null.
System..::.ArgumentException | The tasks argument contains a null element.
System..::.ObjectDisposedException | The Task has been disposed.
System..::.ArgumentOutOfRangeException | millisecondsTimeout is a negative number other than -1, which represents an infinite time-out.

See Also

Task Class
WaitAny Overload
System.Threading.Tasks Namespace


WaitAny Method (Task[], CancellationToken)

[image]

.NET Framework Class Library
Task..::.WaitAny Method (array<Task>[]()[], CancellationToken)
Task Class See Also Send Feedback

Waits for any of the provided Task objects to complete execution.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function WaitAny ( _
    tasks As Task(), _
    cancellationToken As CancellationToken _
) As Integer
C#
public static int WaitAny(
    Task[] tasks,
    CancellationToken cancellationToken
)

Parameters

tasks
Type: array< System.Threading.Tasks..::.Task >[]()[]
An array of Task instances on which to wait.
cancellationToken
Type: System.Threading..::.CancellationToken
A CancellationToken()()() to observe while waiting for a task to complete.

Return Value

The index of the completed task in the tasks array argument.

Exceptions

Exception | Condition
System..::.ArgumentNullException | The tasks argument is null.
System..::.ArgumentException | The tasks argument contains a null element.
System..::.ObjectDisposedException | The Task has been disposed.
System..::.OperationCanceledException | The cancellationToken was canceled.

See Also

Task Class
WaitAny Overload
System.Threading.Tasks Namespace


WaitAny Method (Task[], TimeSpan)

[image]

.NET Framework Class Library
Task..::.WaitAny Method (array<Task>[]()[], TimeSpan)
Task Class See Also Send Feedback

Waits for any of the provided Task objects to complete execution.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function WaitAny ( _
    tasks As Task(), _
    timeout As TimeSpan _
) As Integer
C#
public static int WaitAny(
    Task[] tasks,
    TimeSpan timeout
)

Parameters

tasks
Type: array< System.Threading.Tasks..::.Task >[]()[]
An array of Task instances on which to wait.
timeout
Type: System..::.TimeSpan
A TimeSpan that represents the number of milliseconds to wait, or a TimeSpan that represents -1 milliseconds to wait indefinitely.

Return Value

The index of the completed task in the tasks array argument, or -1 if the timeout occurred.

Exceptions

Exception | Condition
System..::.ArgumentNullException | The tasks argument is null.
System..::.ArgumentException | The tasks argument contains a null element.
System..::.ObjectDisposedException | The Task has been disposed.
System..::.ArgumentOutOfRangeException | timeout is a negative number other than -1 milliseconds, which represents an infinite time-out -or- timeout is greater than MaxValue.

See Also

Task Class
WaitAny Overload
System.Threading.Tasks Namespace


WaitAny Method (Task[], Int32, CancellationToken)

[image]

.NET Framework Class Library
Task..::.WaitAny Method (array<Task>[]()[], Int32, CancellationToken)
Task Class See Also Send Feedback

Waits for any of the provided Task objects to complete execution.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function WaitAny ( _
    tasks As Task(), _
    millisecondsTimeout As Integer, _
    cancellationToken As CancellationToken _
) As Integer
C#
public static int WaitAny(
    Task[] tasks,
    int millisecondsTimeout,
    CancellationToken cancellationToken
)

Parameters

tasks
Type: array< System.Threading.Tasks..::.Task >[]()[]
An array of Task instances on which to wait.
millisecondsTimeout
Type: System..::.Int32
The number of milliseconds to wait, or Infinite (-1) to wait indefinitely.
cancellationToken
Type: System.Threading..::.CancellationToken
A CancellationToken()()() to observe while waiting for a task to complete.

Return Value

The index of the completed task in the tasks array argument, or -1 if the timeout occurred.

Exceptions

Exception | Condition
System..::.ArgumentNullException | The tasks argument is null.
System..::.ArgumentException | The tasks argument contains a null element.
System..::.ObjectDisposedException | The Task has been disposed.
System..::.ArgumentOutOfRangeException | millisecondsTimeout is a negative number other than -1, which represents an infinite time-out.
System..::.OperationCanceledException | The cancellationToken was canceled.

See Also

Task Class
WaitAny Overload
System.Threading.Tasks Namespace


Task Properties

[image] [image]

.NET Framework Class Library
Task Properties
Task Class See Also Send Feedback

The Task type exposes the following members.

Properties

Name | Description
AsyncState | Gets the state object supplied when the Task was created, or null if none was supplied.
CreationOptions | Gets the TaskCreationOptions used to create this task.
CurrentId | Returns the unique ID of the currently executing Task.
Exception | Gets the Exception that caused the Task to end prematurely. If the Task completed successfully or has not yet thrown any exceptions, this will return null.
Factory | Provides access to factory methods for creating Task and Task<(Of <(TResult>)>) instances.
Id | Gets a unique ID for this Task instance.
IsCanceled | Gets whether this Task instance has completed execution due to being canceled.
IsCompleted | Gets whether this Task has completed.
IsFaulted | Gets whether the Task completed due to an unhandled exception.
Status | Gets the TaskStatus of this Task.

Explicit Interface Implementations

Name | Description
IAsyncResult..::.AsyncWaitHandle | Gets a WaitHandle that can be used to wait for the task to complete.
IAsyncResult..::.CompletedSynchronously | Gets an indication of whether the asynchronous operation completed synchronously.

See Also

Task Class
System.Threading.Tasks Namespace


IAsyncResult.AsyncWaitHandle Property

[image]

.NET Framework Class Library
Task..::.IAsyncResult..::.AsyncWaitHandle Property
Task Class See Also Send Feedback

Gets a WaitHandle that can be used to wait for the task to complete.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Private ReadOnly Property AsyncWaitHandle As WaitHandle
    Implements IAsyncResult.AsyncWaitHandle
C#
WaitHandle IAsyncResult.AsyncWaitHandle { get; }

Implements

IAsyncResult..::.AsyncWaitHandle

Remarks

Using the wait functionality provided by Wait()()() should be preferred over using AsyncWaitHandle for similar functionality.

Exceptions

Exception | Condition
System..::.ObjectDisposedException | The Task has been disposed.

See Also

Task Class
System.Threading.Tasks Namespace


IAsyncResult.CompletedSynchronously Property

[image]

.NET Framework Class Library
Task..::.IAsyncResult..::.CompletedSynchronously Property
Task Class See Also Send Feedback

Gets an indication of whether the asynchronous operation completed synchronously.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Private ReadOnly Property CompletedSynchronously As Boolean
    Implements IAsyncResult.CompletedSynchronously
C#
bool IAsyncResult.CompletedSynchronously { get; }

Field Value

true if the asynchronous operation completed synchronously; otherwise, false.

Implements

IAsyncResult..::.CompletedSynchronously

See Also

Task Class
System.Threading.Tasks Namespace


AsyncState Property

[image]

.NET Framework Class Library
Task..::.AsyncState Property
Task Class See Also Send Feedback

Gets the state object supplied when the Task was created, or null if none was supplied.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public ReadOnly Property AsyncState As Object
C#
public Object AsyncState { get; }

Implements

IAsyncResult..::.AsyncState

See Also

Task Class
System.Threading.Tasks Namespace


CreationOptions Property

[image]

.NET Framework Class Library
Task..::.CreationOptions Property
Task Class See Also Send Feedback

Gets the TaskCreationOptions used to create this task.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public ReadOnly Property CreationOptions As TaskCreationOptions
C#
public TaskCreationOptions CreationOptions { get; }

See Also

Task Class
System.Threading.Tasks Namespace


CurrentId Property

[image]

.NET Framework Class Library
Task..::.CurrentId Property
Task Class See Also Send Feedback

Returns the unique ID of the currently executing Task.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared ReadOnly Property CurrentId As Nullable(Of Integer)
C#
public static Nullable<int> CurrentId { get; }

See Also

Task Class
System.Threading.Tasks Namespace


Exception Property

[image]

.NET Framework Class Library
Task..::.Exception Property
Task Class See Also Send Feedback

Gets the Exception that caused the Task to end prematurely. If the Task completed successfully or has not yet thrown any exceptions, this will return null.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public ReadOnly Property Exception As AggregateException
C#
public AggregateException Exception { get; }

Remarks

Tasks that throw unhandled exceptions store the resulting exception and propagate it wrapped in a AggregateException in calls to Wait or in accesses to the Exception property. Any exceptions not observed by the time the Task instance is garbage collected will be propagated on the finalizer thread.

Exceptions

Exception | Condition
System..::.ObjectDisposedException | The Task has been disposed.

See Also

Task Class
System.Threading.Tasks Namespace


Factory Property

[image]

.NET Framework Class Library
Task..::.Factory Property
Task Class See Also Send Feedback

Provides access to factory methods for creating Task and Task<(Of <(TResult>)>) instances.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared ReadOnly Property Factory As TaskFactory
C#
public static TaskFactory Factory { get; }

Remarks

The factory returned from Factory is a default instance of TaskFactory, as would result from using the default constructor on TaskFactory.

See Also

Task Class
System.Threading.Tasks Namespace


Id Property

[image]

.NET Framework Class Library
Task..::.Id Property
Task Class See Also Send Feedback

Gets a unique ID for this Task instance.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public ReadOnly Property Id As Integer
C#
public int Id { get; }

Remarks

Task IDs are assigned on-demand and do not necessarily represent the order in the which Task instances were created.

See Also

Task Class
System.Threading.Tasks Namespace


IsCanceled Property

[image]

.NET Framework Class Library
Task..::.IsCanceled Property
Task Class See Also Send Feedback

Gets whether this Task instance has completed execution due to being canceled.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public ReadOnly Property IsCanceled As Boolean
C#
public bool IsCanceled { get; }

Remarks

A Task will complete in Canceled state either if its CancellationToken was marked for cancellation before the task started executing, or if the task acknowledged the cancellation request on its already signaled CancellationToken by throwing an OperationCanceledException that bears the same CancellationToken.

See Also

Task Class
System.Threading.Tasks Namespace


IsCompleted Property

[image]

.NET Framework Class Library
Task..::.IsCompleted Property
Task Class See Also Send Feedback

Gets whether this Task has completed.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public ReadOnly Property IsCompleted As Boolean
C#
public bool IsCompleted { get; }

Implements

IAsyncResult..::.IsCompleted

Remarks

IsCompleted will return true when the Task is in one of the three final states: RanToCompletion, Faulted, or Canceled.

See Also

Task Class
System.Threading.Tasks Namespace


IsFaulted Property

[image]

.NET Framework Class Library
Task..::.IsFaulted Property
Task Class See Also Send Feedback

Gets whether the Task completed due to an unhandled exception.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public ReadOnly Property IsFaulted As Boolean
C#
public bool IsFaulted { get; }

Remarks

If IsFaulted is true, the Task's Status will be equal to TaskStatus.Faulted, and its Exception property will be non-null.

See Also

Task Class
System.Threading.Tasks Namespace


Status Property

[image]

.NET Framework Class Library
Task..::.Status Property
Task Class See Also Send Feedback

Gets the TaskStatus of this Task.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public ReadOnly Property Status As TaskStatus
C#
public TaskStatus Status { get; }

See Also

Task Class
System.Threading.Tasks Namespace


Task(TResult) Class

[image]

.NET Framework Class Library
Task<(Of <(TResult>)>) Class
See Also Send Feedback

Represents an asynchronous operation that produces a result at some time in the future.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
<HostProtectionAttribute(SecurityAction.LinkDemand, Synchronization := True,  _
    ExternalThreading := True)> _
Public Class Task(Of TResult) _
    Inherits Task
C#
[HostProtectionAttribute(SecurityAction.LinkDemand, Synchronization = true,
    ExternalThreading = true)]
public class Task<TResult> : Task

Type Parameters

TResult
The type of the result produced by this Task<(Of <(TResult>)>).

Remarks

Task<(Of <(TResult>)>) instances may be created in a variety of ways. The most common approach is by using the task's Factory property to retrieve a TaskFactory<(Of <(TResult>)>) instance that can be used to create tasks for several purposes. For example, to create a Task<(Of <(TResult>)>) that runs a function, the factory's StartNew method may be used:

Copy Code
            // C#
            var t = Task<int>.Factory.StartNew(() => GenerateResult());
            - or -
            var t = Task.Factory.StartNew(() => GenerateResult());

            ' Visual Basic
            Dim t = Task<int>.Factory.StartNew(Function() GenerateResult())
            - or -
            Dim t = Task.Factory.StartNew(Function() GenerateResult())

The Task<(Of <(TResult>)>) class also provides constructors that initialize the task but that do not schedule it for execution. For performance reasons, the StartNew method should be the preferred mechanism for creating and scheduling computational tasks, but for scenarios where creation and scheduling must be separated, the constructors may be used, and the task's Start method may then be used to schedule the task for execution at a later time.

All members of Task<(Of <(TResult>)>), except for Dispose, are thread-safe and may be used from multiple threads concurrently.

Inheritance Hierarchy

System..::.Object
System.Threading.Tasks..::.Task
System.Threading.Tasks..::.Task<(Of <(TResult>)>)

See Also

System.Threading.Tasks Namespace


Task(TResult) Constructor

[image] [image]

.NET Framework Class Library
Task<(Of <(TResult>)>) Constructor
Task<(Of <(TResult>)>) Class See Also Send Feedback

Overload List

Name | Description
Task<(Of <(TResult>)>)(Func<(Of <(TResult>)>)) | Initializes a new Task<(Of <(TResult>)>) with the specified function.
Task<(Of <(TResult>)>)(Func<(Of <(TResult>)>), CancellationToken) | Initializes a new Task<(Of <(TResult>)>) with the specified function.
Task<(Of <(TResult>)>)(Func<(Of <(TResult>)>), TaskCreationOptions) | Initializes a new Task<(Of <(TResult>)>) with the specified function and creation options.
Task<(Of <(TResult>)>)(Func<(Of <(Object, TResult>)>), Object) | Initializes a new Task<(Of <(TResult>)>) with the specified function and state.
Task<(Of <(TResult>)>)(Func<(Of <(TResult>)>), CancellationToken, TaskCreationOptions) | Initializes a new Task<(Of <(TResult>)>) with the specified function and creation options.
Task<(Of <(TResult>)>)(Func<(Of <(Object, TResult>)>), Object, CancellationToken) | Initializes a new Task<(Of <(TResult>)>) with the specified action, state, and options.
Task<(Of <(TResult>)>)(Func<(Of <(Object, TResult>)>), Object, TaskCreationOptions) | Initializes a new Task<(Of <(TResult>)>) with the specified action, state, and options.
Task<(Of <(TResult>)>)(Func<(Of <(Object, TResult>)>), Object, CancellationToken, TaskCreationOptions) | Initializes a new Task<(Of <(TResult>)>) with the specified action, state, and options.

See Also

Task<(Of <(TResult>)>) Class
System.Threading.Tasks Namespace


Task(TResult) Constructor (Func(TResult))

[image]

.NET Framework Class Library
Task<(Of <(TResult>)>) Constructor (Func<(Of <(TResult>)>))
Task<(Of <(TResult>)>) Class See Also Send Feedback

Initializes a new Task<(Of <(TResult>)>) with the specified function.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Sub New ( _
    function As Func(Of TResult) _
)
C#
public Task(
    Func<TResult> function
)

Parameters

function
Type: System..::.Func<(Of <( TResult >)>)
The delegate that represents the code to execute in the task. When the function has completed, the task's Result property will be set to return the result value of the function.

Exceptions

Exception | Condition
System..::.ArgumentException | The function argument is null.

See Also

Task<(Of <(TResult>)>) Class
Task<(Of <(TResult>)>) Overload
System.Threading.Tasks Namespace


Task(TResult) Constructor (Func(TResult), CancellationToken)

[image]

.NET Framework Class Library
Task<(Of <(TResult>)>) Constructor (Func<(Of <(TResult>)>), CancellationToken)
Task<(Of <(TResult>)>) Class See Also Send Feedback

Initializes a new Task<(Of <(TResult>)>) with the specified function.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Sub New ( _
    function As Func(Of TResult), _
    cancellationToken As CancellationToken _
)
C#
public Task(
    Func<TResult> function,
    CancellationToken cancellationToken
)

Parameters

function
Type: System..::.Func<(Of <( TResult >)>)
The delegate that represents the code to execute in the task. When the function has completed, the task's Result property will be set to return the result value of the function.
cancellationToken
Type: System.Threading..::.CancellationToken
The CancellationToken to be assigned to this task.

Exceptions

Exception | Condition
System..::.ArgumentException | The function argument is null.
System..::.ObjectDisposedException | The provided CancellationToken has already been disposed.

See Also

Task<(Of <(TResult>)>) Class
Task<(Of <(TResult>)>) Overload
System.Threading.Tasks Namespace


Task(TResult) Constructor (Func(TResult), TaskCreationOptions)

[image]

.NET Framework Class Library
Task<(Of <(TResult>)>) Constructor (Func<(Of <(TResult>)>), TaskCreationOptions)
Task<(Of <(TResult>)>) Class See Also Send Feedback

Initializes a new Task<(Of <(TResult>)>) with the specified function and creation options.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Sub New ( _
    function As Func(Of TResult), _
    creationOptions As TaskCreationOptions _
)
C#
public Task(
    Func<TResult> function,
    TaskCreationOptions creationOptions
)

Parameters

function
Type: System..::.Func<(Of <( TResult >)>)
The delegate that represents the code to execute in the task. When the function has completed, the task's Result property will be set to return the result value of the function.
creationOptions
Type: System.Threading.Tasks..::.TaskCreationOptions
The TaskCreationOptions used to customize the task's behavior.

Exceptions

Exception | Condition
System..::.ArgumentException | The function argument is null.
System..::.ArgumentOutOfRangeException | The creationOptions argument specifies an invalid value for TaskCreationOptions.

See Also

Task<(Of <(TResult>)>) Class
Task<(Of <(TResult>)>) Overload
System.Threading.Tasks Namespace


Task(TResult) Constructor (Func(Object, TResult), Object)

[image]

.NET Framework Class Library
Task<(Of <(TResult>)>) Constructor (Func<(Of <(Object, TResult>)>), Object)
Task<(Of <(TResult>)>) Class See Also Send Feedback

Initializes a new Task<(Of <(TResult>)>) with the specified function and state.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Sub New ( _
    function As Func(Of Object, TResult), _
    state As Object _
)
C#
public Task(
    Func<Object, TResult> function,
    Object state
)

Parameters

function
Type: System..::.Func<(Of <(Object, TResult >)>)
The delegate that represents the code to execute in the task. When the function has completed, the task's Result property will be set to return the result value of the function.
state
Type: System..::.Object
An object representing data to be used by the action.

Exceptions

Exception | Condition
System..::.ArgumentException | The function argument is null.

See Also

Task<(Of <(TResult>)>) Class
Task<(Of <(TResult>)>) Overload
System.Threading.Tasks Namespace


Task(TResult) Constructor (Func(TResult), CancellationToken, TaskCreationOptions)

[image]

.NET Framework Class Library
Task<(Of <(TResult>)>) Constructor (Func<(Of <(TResult>)>), CancellationToken, TaskCreationOptions)
Task<(Of <(TResult>)>) Class See Also Send Feedback

Initializes a new Task<(Of <(TResult>)>) with the specified function and creation options.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Sub New ( _
    function As Func(Of TResult), _
    cancellationToken As CancellationToken, _
    creationOptions As TaskCreationOptions _
)
C#
public Task(
    Func<TResult> function,
    CancellationToken cancellationToken,
    TaskCreationOptions creationOptions
)

Parameters

function
Type: System..::.Func<(Of <( TResult >)>)
The delegate that represents the code to execute in the task. When the function has completed, the task's Result property will be set to return the result value of the function.
cancellationToken
Type: System.Threading..::.CancellationToken
The CancellationToken that will be assigned to the new task.
creationOptions
Type: System.Threading.Tasks..::.TaskCreationOptions
The TaskCreationOptions used to customize the task's behavior.

Exceptions

Exception | Condition
System..::.ArgumentException | The function argument is null.
System..::.ArgumentOutOfRangeException | The creationOptions argument specifies an invalid value for TaskCreationOptions.
System..::.ObjectDisposedException | The provided CancellationToken has already been disposed.

See Also

Task<(Of <(TResult>)>) Class
Task<(Of <(TResult>)>) Overload
System.Threading.Tasks Namespace


Task(TResult) Constructor (Func(Object, TResult), Object, CancellationToken)

[image]

.NET Framework Class Library
Task<(Of <(TResult>)>) Constructor (Func<(Of <(Object, TResult>)>), Object, CancellationToken)
Task<(Of <(TResult>)>) Class See Also Send Feedback

Initializes a new Task<(Of <(TResult>)>) with the specified action, state, and options.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Sub New ( _
    function As Func(Of Object, TResult), _
    state As Object, _
    cancellationToken As CancellationToken _
)
C#
public Task(
    Func<Object, TResult> function,
    Object state,
    CancellationToken cancellationToken
)

Parameters

function
Type: System..::.Func<(Of <(Object, TResult >)>)
The delegate that represents the code to execute in the task. When the function has completed, the task's Result property will be set to return the result value of the function.
state
Type: System..::.Object
An object representing data to be used by the function.
cancellationToken
Type: System.Threading..::.CancellationToken
The CancellationToken to be assigned to the new task.

Exceptions

Exception | Condition
System..::.ArgumentException | The function argument is null.
System..::.ObjectDisposedException | The provided CancellationToken has already been disposed.

See Also

Task<(Of <(TResult>)>) Class
Task<(Of <(TResult>)>) Overload
System.Threading.Tasks Namespace


Task(TResult) Constructor (Func(Object, TResult), Object, TaskCreationOptions)

[image]

.NET Framework Class Library
Task<(Of <(TResult>)>) Constructor (Func<(Of <(Object, TResult>)>), Object, TaskCreationOptions)
Task<(Of <(TResult>)>) Class See Also Send Feedback

Initializes a new Task<(Of <(TResult>)>) with the specified action, state, and options.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Sub New ( _
    function As Func(Of Object, TResult), _
    state As Object, _
    creationOptions As TaskCreationOptions _
)
C#
public Task(
    Func<Object, TResult> function,
    Object state,
    TaskCreationOptions creationOptions
)

Parameters

function
Type: System..::.Func<(Of <(Object, TResult >)>)
The delegate that represents the code to execute in the task. When the function has completed, the task's Result property will be set to return the result value of the function.
state
Type: System..::.Object
An object representing data to be used by the function.
creationOptions
Type: System.Threading.Tasks..::.TaskCreationOptions
The TaskCreationOptions used to customize the task's behavior.

Exceptions

Exception | Condition
System..::.ArgumentException | The function argument is null.
System..::.ArgumentOutOfRangeException | The creationOptions argument specifies an invalid value for TaskCreationOptions.

See Also

Task<(Of <(TResult>)>) Class
Task<(Of <(TResult>)>) Overload
System.Threading.Tasks Namespace


Task(TResult) Constructor (Func(Object, TResult), Object, CancellationToken, TaskCreationOptions)

[image]

.NET Framework Class Library
Task<(Of <(TResult>)>) Constructor (Func<(Of <(Object, TResult>)>), Object, CancellationToken, TaskCreationOptions)
Task<(Of <(TResult>)>) Class See Also Send Feedback

Initializes a new Task<(Of <(TResult>)>) with the specified action, state, and options.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Sub New ( _
    function As Func(Of Object, TResult), _
    state As Object, _
    cancellationToken As CancellationToken, _
    creationOptions As TaskCreationOptions _
)
C#
public Task(
    Func<Object, TResult> function,
    Object state,
    CancellationToken cancellationToken,
    TaskCreationOptions creationOptions
)

Parameters

function
Type: System..::.Func<(Of <(Object, TResult >)>)
The delegate that represents the code to execute in the task. When the function has completed, the task's Result property will be set to return the result value of the function.
state
Type: System..::.Object
An object representing data to be used by the function.
cancellationToken
Type: System.Threading..::.CancellationToken
The CancellationToken to be assigned to the new task.
creationOptions
Type: System.Threading.Tasks..::.TaskCreationOptions
The TaskCreationOptions used to customize the task's behavior.

Exceptions

Exception | Condition
System..::.ArgumentException | The function argument is null.
System..::.ArgumentOutOfRangeException | The creationOptions argument specifies an invalid value for TaskCreationOptions.
System..::.ObjectDisposedException | The provided CancellationToken has already been disposed.

See Also

Task<(Of <(TResult>)>) Class
Task<(Of <(TResult>)>) Overload
System.Threading.Tasks Namespace


Task(TResult) Methods

[image] [image]

.NET Framework Class Library
Task<(Of <(TResult>)>) Methods
Task<(Of <(TResult>)>) Class See Also Send Feedback

The Task<(Of <(TResult>)>) type exposes the following members.

Methods

Name | Description
ContinueWith | Overloaded.
Dispose | Overloaded.
Equals | (Inherited from Object.)
Finalize | (Inherited from Object.)
GetHashCode | (Inherited from Object.)
GetType | (Inherited from Object.)
MemberwiseClone | (Inherited from Object.)
RunSynchronously | Overloaded.
Start | Overloaded.
ToString | (Inherited from Object.)
Wait | Overloaded.

See Also

Task<(Of <(TResult>)>) Class
System.Threading.Tasks Namespace


ContinueWith Method

[image] [image]

.NET Framework Class Library
Task<(Of <(TResult>)>)..::.ContinueWith Method
Task<(Of <(TResult>)>) Class See Also Send Feedback

Overload List

Name | Description
ContinueWith(Action<(Of <(Task>)>)) | Creates a continuation that executes when the target Task completes. (Inherited from Task.)
ContinueWith<(Of <(TResult>)>)(Func<(Of <(Task, TResult>)>)) | Creates a continuation that executes when the target Task completes. (Inherited from Task.)
ContinueWith(Action<(Of <(Task<(Of <(TResult>)>)>)>)) | Creates a continuation that executes when the target Task<(Of <(TResult>)>) completes.
ContinueWith<(Of <(TNewResult>)>)(Func<(Of <(Task<(Of <(TResult>)>), TNewResult>)>)) | Creates a continuation that executes when the target Task<(Of <(TResult>)>) completes.
ContinueWith(Action<(Of <(Task>)>), CancellationToken) | Creates a continuation that executes when the target Task completes. (Inherited from Task.)
ContinueWith(Action<(Of <(Task>)>), TaskContinuationOptions) | Creates a continuation that executes when the target Task completes. (Inherited from Task.)
ContinueWith(Action<(Of <(Task>)>), TaskScheduler) | Creates a continuation that executes when the target Task completes. (Inherited from Task.)
ContinueWith<(Of <(TResult>)>)(Func<(Of <(Task, TResult>)>), CancellationToken) | Creates a continuation that executes when the target Task completes. (Inherited from Task.)
ContinueWith<(Of <(TResult>)>)(Func<(Of <(Task, TResult>)>), TaskContinuationOptions) | Creates a continuation that executes when the target Task completes. (Inherited from Task.)
ContinueWith<(Of <(TResult>)>)(Func<(Of <(Task, TResult>)>), TaskScheduler) | Creates a continuation that executes when the target Task completes. (Inherited from Task.)
ContinueWith(Action<(Of <(Task<(Of <(TResult>)>)>)>), CancellationToken) | Creates a continuation that executes when the target Task<(Of <(TResult>)>) completes.
ContinueWith(Action<(Of <(Task<(Of <(TResult>)>)>)>), TaskContinuationOptions) | Creates a continuation that executes when the target Task<(Of <(TResult>)>) completes.
ContinueWith(Action<(Of <(Task<(Of <(TResult>)>)>)>), TaskScheduler) | Creates a continuation that executes when the target Task<(Of <(TResult>)>) completes.
ContinueWith<(Of <(TNewResult>)>)(Func<(Of <(Task<(Of <(TResult>)>), TNewResult>)>), CancellationToken) | Creates a continuation that executes when the target Task<(Of <(TResult>)>) completes.
ContinueWith<(Of <(TNewResult>)>)(Func<(Of <(Task<(Of <(TResult>)>), TNewResult>)>), TaskContinuationOptions) | Creates a continuation that executes when the target Task<(Of <(TResult>)>) completes.
ContinueWith<(Of <(TNewResult>)>)(Func<(Of <(Task<(Of <(TResult>)>), TNewResult>)>), TaskScheduler) | Creates a continuation that executes when the target Task<(Of <(TResult>)>) completes.
ContinueWith(Action<(Of <(Task>)>), CancellationToken, TaskContinuationOptions, TaskScheduler) | Creates a continuation that executes when the target Task completes. (Inherited from Task.)
ContinueWith<(Of <(TResult>)>)(Func<(Of <(Task, TResult>)>), CancellationToken, TaskContinuationOptions, TaskScheduler) | Creates a continuation that executes when the target Task completes. (Inherited from Task.)
ContinueWith(Action<(Of <(Task<(Of <(TResult>)>)>)>), CancellationToken, TaskContinuationOptions, TaskScheduler) | Creates a continuation that executes when the target Task<(Of <(TResult>)>) completes.
ContinueWith<(Of <(TNewResult>)>)(Func<(Of <(Task<(Of <(TResult>)>), TNewResult>)>), CancellationToken, TaskContinuationOptions, TaskScheduler) | Creates a continuation that executes when the target Task<(Of <(TResult>)>) completes.

See Also

Task<(Of <(TResult>)>) Class
System.Threading.Tasks Namespace


ContinueWith Method (Action(Task(TResult)))

[image]

.NET Framework Class Library
Task<(Of <(TResult>)>)..::.ContinueWith Method (Action<(Of <(Task<(Of <(TResult>)>)>)>))
Task<(Of <(TResult>)>) Class See Also Send Feedback

Creates a continuation that executes when the target Task<(Of <(TResult>)>) completes.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Function ContinueWith ( _
    continuationAction As Action(Of Task(Of TResult)) _
) As Task
C#
public Task ContinueWith(
    Action<Task<TResult>> continuationAction
)

Parameters

continuationAction
Type: System..::.Action<(Of <( Task <(Of <( TResult >)>)>)>)
An action to run when the Task<(Of <(TResult>)>) completes. When run, the delegate will be passed the completed task as an argument.

Return Value

A new continuation Task.

Remarks

The returned Task will not be scheduled for execution until the current task has completed, whether it completes due to running to completion successfully, faulting due to an unhandled exception, or exiting out early due to being canceled.

Exceptions

Exception | Condition
System..::.ArgumentNullException | The continuationAction argument is null.
System..::.ObjectDisposedException | The Task<(Of <(TResult>)>) has been disposed.

See Also

Task<(Of <(TResult>)>) Class
ContinueWith Overload
System.Threading.Tasks Namespace


ContinueWith(TNewResult) Method (Func(Task(TResult), TNewResult))

[image]

.NET Framework Class Library
Task<(Of <(TResult>)>)..::.ContinueWith<(Of <(TNewResult>)>) Method (Func<(Of <(Task<(Of <(TResult>)>), TNewResult>)>))
Task<(Of <(TResult>)>) Class See Also Send Feedback

Creates a continuation that executes when the target Task<(Of <(TResult>)>) completes.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Function ContinueWith(Of TNewResult) ( _
    continuationFunction As Func(Of Task(Of TResult), TNewResult) _
) As Task(Of TNewResult)
C#
public Task<TNewResult> ContinueWith<TNewResult>(
    Func<Task<TResult>, TNewResult> continuationFunction
)

Parameters

continuationFunction
Type: System..::.Func<(Of <( Task <(Of <( TResult >)>), TNewResult>)>)
A function to run when the Task<(Of <(TResult>)>) completes. When run, the delegate will be passed the completed task as an argument.

Type Parameters

TNewResult
The type of the result produced by the continuation.

Return Value

A new continuation Task<(Of <(TResult>)>).

Remarks

The returned Task<(Of <(TResult>)>) will not be scheduled for execution until the current task has completed, whether it completes due to running to completion successfully, faulting due to an unhandled exception, or exiting out early due to being canceled.

Exceptions

Exception | Condition
System..::.ArgumentNullException | The continuationFunction argument is null.
System..::.ObjectDisposedException | The Task<(Of <(TResult>)>) has been disposed.

See Also

Task<(Of <(TResult>)>) Class
ContinueWith Overload
System.Threading.Tasks Namespace


ContinueWith Method (Action(Task(TResult)), CancellationToken)

[image]

.NET Framework Class Library
Task<(Of <(TResult>)>)..::.ContinueWith Method (Action<(Of <(Task<(Of <(TResult>)>)>)>), CancellationToken)
Task<(Of <(TResult>)>) Class See Also Send Feedback

Creates a continuation that executes when the target Task<(Of <(TResult>)>) completes.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Function ContinueWith ( _
    continuationAction As Action(Of Task(Of TResult)), _
    cancellationToken As CancellationToken _
) As Task
C#
public Task ContinueWith(
    Action<Task<TResult>> continuationAction,
    CancellationToken cancellationToken
)

Parameters

continuationAction
Type: System..::.Action<(Of <( Task <(Of <( TResult >)>)>)>)
An action to run when the Task<(Of <(TResult>)>) completes. When run, the delegate will be passed the completed task as an argument.
cancellationToken
Type: System.Threading..::.CancellationToken
The CancellationToken that will be assigned to the new continuation task.

Return Value

A new continuation Task.

Remarks

The returned Task will not be scheduled for execution until the current task has completed, whether it completes due to running to completion successfully, faulting due to an unhandled exception, or exiting out early due to being canceled.

Exceptions

Exception | Condition
System..::.ArgumentNullException | The continuationAction argument is null.
System..::.ObjectDisposedException | The Task<(Of <(TResult>)>) has been disposed.
System..::.ObjectDisposedException | The provided CancellationToken has already been disposed.

See Also

Task<(Of <(TResult>)>) Class
ContinueWith Overload
System.Threading.Tasks Namespace


ContinueWith Method (Action(Task(TResult)), TaskContinuationOptions)

[image]

.NET Framework Class Library
Task<(Of <(TResult>)>)..::.ContinueWith Method (Action<(Of <(Task<(Of <(TResult>)>)>)>), TaskContinuationOptions)
Task<(Of <(TResult>)>) Class See Also Send Feedback

Creates a continuation that executes when the target Task<(Of <(TResult>)>) completes.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Function ContinueWith ( _
    continuationAction As Action(Of Task(Of TResult)), _
    continuationOptions As TaskContinuationOptions _
) As Task
C#
public Task ContinueWith(
    Action<Task<TResult>> continuationAction,
    TaskContinuationOptions continuationOptions
)

Parameters

continuationAction
Type: System..::.Action<(Of <( Task <(Of <( TResult >)>)>)>)
An action to run when the Task<(Of <(TResult>)>) completes. When run, the delegate will be passed the completed task as an argument.
continuationOptions
Type: System.Threading.Tasks..::.TaskContinuationOptions
Options for when the continuation is scheduled and how it behaves. This includes criteria, such as OnlyOnCanceled, as well as execution options, such as ExecuteSynchronously.

Return Value

A new continuation Task.

Remarks

The returned Task will not be scheduled for execution until the current task has completed. If the continuation criteria specified through the continuationOptions parameter are not met, the continuation task will be canceled instead of scheduled.

Exceptions

Exception | Condition
System..::.ArgumentNullException | The continuationAction argument is null.
System..::.ArgumentOutOfRangeException | The continuationOptions argument specifies an invalid value for TaskContinuationOptions.
System..::.ObjectDisposedException | The Task<(Of <(TResult>)>) has been disposed.

See Also

Task<(Of <(TResult>)>) Class
ContinueWith Overload
System.Threading.Tasks Namespace


ContinueWith Method (Action(Task(TResult)), TaskScheduler)

[image]

.NET Framework Class Library
Task<(Of <(TResult>)>)..::.ContinueWith Method (Action<(Of <(Task<(Of <(TResult>)>)>)>), TaskScheduler)
Task<(Of <(TResult>)>) Class See Also Send Feedback

Creates a continuation that executes when the target Task<(Of <(TResult>)>) completes.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Function ContinueWith ( _
    continuationAction As Action(Of Task(Of TResult)), _
    scheduler As TaskScheduler _
) As Task
C#
public Task ContinueWith(
    Action<Task<TResult>> continuationAction,
    TaskScheduler scheduler
)

Parameters

continuationAction
Type: System..::.Action<(Of <( Task <(Of <( TResult >)>)>)>)
An action to run when the Task<(Of <(TResult>)>) completes. When run, the delegate will be passed the completed task as an argument.
scheduler
Type: System.Threading.Tasks..::.TaskScheduler
The TaskScheduler to associate with the continuation task and to use for its execution.

Return Value

A new continuation Task.

Remarks

The returned Task will not be scheduled for execution until the current task has completed, whether it completes due to running to completion successfully, faulting due to an unhandled exception, or exiting out early due to being canceled.

Exceptions

Exception | Condition
System..::.ArgumentNullException | The continuationAction argument is null.
System..::.ArgumentNullException | The scheduler argument is null.
System..::.ObjectDisposedException | The Task<(Of <(TResult>)>) has been disposed.

See Also

Task<(Of <(TResult>)>) Class
ContinueWith Overload
System.Threading.Tasks Namespace


ContinueWith(TNewResult) Method (Func(Task(TResult), TNewResult), CancellationToken)

[image]

.NET Framework Class Library
Task<(Of <(TResult>)>)..::.ContinueWith<(Of <(TNewResult>)>) Method (Func<(Of <(Task<(Of <(TResult>)>), TNewResult>)>), CancellationToken)
Task<(Of <(TResult>)>) Class See Also Send Feedback

Creates a continuation that executes when the target Task<(Of <(TResult>)>) completes.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Function ContinueWith(Of TNewResult) ( _
    continuationFunction As Func(Of Task(Of TResult), TNewResult), _
    cancellationToken As CancellationToken _
) As Task(Of TNewResult)
C#
public Task<TNewResult> ContinueWith<TNewResult>(
    Func<Task<TResult>, TNewResult> continuationFunction,
    CancellationToken cancellationToken
)

Parameters

continuationFunction
Type: System..::.Func<(Of <( Task <(Of <( TResult >)>), TNewResult>)>)
A function to run when the Task<(Of <(TResult>)>) completes. When run, the delegate will be passed the completed task as an argument.
cancellationToken
Type: System.Threading..::.CancellationToken
The CancellationToken that will be assigned to the new task.

Type Parameters

TNewResult
The type of the result produced by the continuation.

Return Value

A new continuation Task<(Of <(TResult>)>).

Remarks

The returned Task<(Of <(TResult>)>) will not be scheduled for execution until the current task has completed, whether it completes due to running to completion successfully, faulting due to an unhandled exception, or exiting out early due to being canceled.

Exceptions

Exception | Condition
System..::.ArgumentNullException | The continuationFunction argument is null.
System..::.ObjectDisposedException | The Task<(Of <(TResult>)>) has been disposed.
System..::.ObjectDisposedException | The provided CancellationToken has already been disposed.

See Also

Task<(Of <(TResult>)>) Class
ContinueWith Overload
System.Threading.Tasks Namespace


ContinueWith(TNewResult) Method (Func(Task(TResult), TNewResult), TaskContinuationOptions)

[image]

.NET Framework Class Library
Task<(Of <(TResult>)>)..::.ContinueWith<(Of <(TNewResult>)>) Method (Func<(Of <(Task<(Of <(TResult>)>), TNewResult>)>), TaskContinuationOptions)
Task<(Of <(TResult>)>) Class See Also Send Feedback

Creates a continuation that executes when the target Task<(Of <(TResult>)>) completes.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Function ContinueWith(Of TNewResult) ( _
    continuationFunction As Func(Of Task(Of TResult), TNewResult), _
    continuationOptions As TaskContinuationOptions _
) As Task(Of TNewResult)
C#
public Task<TNewResult> ContinueWith<TNewResult>(
    Func<Task<TResult>, TNewResult> continuationFunction,
    TaskContinuationOptions continuationOptions
)

Parameters

continuationFunction
Type: System..::.Func<(Of <( Task <(Of <( TResult >)>), TNewResult>)>)
A function to run when the Task<(Of <(TResult>)>) completes. When run, the delegate will be passed the completed task as an argument.
continuationOptions
Type: System.Threading.Tasks..::.TaskContinuationOptions
Options for when the continuation is scheduled and how it behaves. This includes criteria, such as OnlyOnCanceled, as well as execution options, such as ExecuteSynchronously.

Type Parameters

TNewResult
The type of the result produced by the continuation.

Return Value

A new continuation Task<(Of <(TResult>)>).

Remarks

The returned Task<(Of <(TResult>)>) will not be scheduled for execution until the current task has completed, whether it completes due to running to completion successfully, faulting due to an unhandled exception, or exiting out early due to being canceled.

The continuationFunction, when executed, should return a Task<(Of <(TResult>)>). This task's completion state will be transferred to the task returned from the ContinueWith call.

Exceptions

Exception | Condition
System..::.ArgumentNullException | The continuationFunction argument is null.
System..::.ArgumentOutOfRangeException | The continuationOptions argument specifies an invalid value for TaskContinuationOptions.
System..::.ObjectDisposedException | The Task<(Of <(TResult>)>) has been disposed.

See Also

Task<(Of <(TResult>)>) Class
ContinueWith Overload
System.Threading.Tasks Namespace


ContinueWith(TNewResult) Method (Func(Task(TResult), TNewResult), TaskScheduler)

[image]

.NET Framework Class Library
Task<(Of <(TResult>)>)..::.ContinueWith<(Of <(TNewResult>)>) Method (Func<(Of <(Task<(Of <(TResult>)>), TNewResult>)>), TaskScheduler)
Task<(Of <(TResult>)>) Class See Also Send Feedback

Creates a continuation that executes when the target Task<(Of <(TResult>)>) completes.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Function ContinueWith(Of TNewResult) ( _
    continuationFunction As Func(Of Task(Of TResult), TNewResult), _
    scheduler As TaskScheduler _
) As Task(Of TNewResult)
C#
public Task<TNewResult> ContinueWith<TNewResult>(
    Func<Task<TResult>, TNewResult> continuationFunction,
    TaskScheduler scheduler
)

Parameters

continuationFunction
Type: System..::.Func<(Of <( Task <(Of <( TResult >)>), TNewResult>)>)
A function to run when the Task<(Of <(TResult>)>) completes. When run, the delegate will be passed the completed task as an argument.
scheduler
Type: System.Threading.Tasks..::.TaskScheduler
The TaskScheduler to associate with the continuation task and to use for its execution.

Type Parameters

TNewResult
The type of the result produced by the continuation.

Return Value

A new continuation Task<(Of <(TResult>)>).

Remarks

The returned Task<(Of <(TResult>)>) will not be scheduled for execution until the current task has completed, whether it completes due to running to completion successfully, faulting due to an unhandled exception, or exiting out early due to being canceled.

Exceptions

Exception | Condition
System..::.ArgumentNullException | The continuationFunction argument is null.
System..::.ArgumentNullException | The scheduler argument is null.
System..::.ObjectDisposedException | The Task<(Of <(TResult>)>) has been disposed.

See Also

Task<(Of <(TResult>)>) Class
ContinueWith Overload
System.Threading.Tasks Namespace


ContinueWith Method (Action(Task(TResult)), CancellationToken, TaskContinuationOptions, TaskScheduler)

[image]

.NET Framework Class Library
Task<(Of <(TResult>)>)..::.ContinueWith Method (Action<(Of <(Task<(Of <(TResult>)>)>)>), CancellationToken, TaskContinuationOptions, TaskScheduler)
Task<(Of <(TResult>)>) Class See Also Send Feedback

Creates a continuation that executes when the target Task<(Of <(TResult>)>) completes.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Function ContinueWith ( _
    continuationAction As Action(Of Task(Of TResult)), _
    cancellationToken As CancellationToken, _
    continuationOptions As TaskContinuationOptions, _
    scheduler As TaskScheduler _
) As Task
C#
public Task ContinueWith(
    Action<Task<TResult>> continuationAction,
    CancellationToken cancellationToken,
    TaskContinuationOptions continuationOptions,
    TaskScheduler scheduler
)

Parameters

continuationAction
Type: System..::.Action<(Of <( Task <(Of <( TResult >)>)>)>)
An action to run when the Task<(Of <(TResult>)>) completes. When run, the delegate will be passed the completed task as an argument.
cancellationToken
Type: System.Threading..::.CancellationToken
The CancellationToken that will be assigned to the new continuation task.
continuationOptions
Type: System.Threading.Tasks..::.TaskContinuationOptions
Options for when the continuation is scheduled and how it behaves. This includes criteria, such as OnlyOnCanceled, as well as execution options, such as ExecuteSynchronously.
scheduler
Type: System.Threading.Tasks..::.TaskScheduler
The TaskScheduler to associate with the continuation task and to use for its execution.

Return Value

A new continuation Task.

Remarks

The returned Task will not be scheduled for execution until the current task has completed. If the criteria specified through the continuationOptions parameter are not met, the continuation task will be canceled instead of scheduled.

Exceptions

Exception | Condition
System..::.ArgumentNullException | The continuationAction argument is null.
System..::.ArgumentOutOfRangeException | The continuationOptions argument specifies an invalid value for TaskContinuationOptions.
System..::.ArgumentNullException | The scheduler argument is null.
System..::.ObjectDisposedException | The Task<(Of <(TResult>)>) has been disposed.
System..::.ObjectDisposedException | The provided CancellationToken has already been disposed.

See Also

Task<(Of <(TResult>)>) Class
ContinueWith Overload
System.Threading.Tasks Namespace


ContinueWith(TNewResult) Method (Func(Task(TResult), TNewResult), CancellationToken, TaskContinuationOptions, TaskScheduler)

[image]

.NET Framework Class Library
Task<(Of <(TResult>)>)..::.ContinueWith<(Of <(TNewResult>)>) Method (Func<(Of <(Task<(Of <(TResult>)>), TNewResult>)>), CancellationToken, TaskContinuationOptions, TaskScheduler)
Task<(Of <(TResult>)>) Class See Also Send Feedback

Creates a continuation that executes when the target Task<(Of <(TResult>)>) completes.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Function ContinueWith(Of TNewResult) ( _
    continuationFunction As Func(Of Task(Of TResult), TNewResult), _
    cancellationToken As CancellationToken, _
    continuationOptions As TaskContinuationOptions, _
    scheduler As TaskScheduler _
) As Task(Of TNewResult)
C#
public Task<TNewResult> ContinueWith<TNewResult>(
    Func<Task<TResult>, TNewResult> continuationFunction,
    CancellationToken cancellationToken,
    TaskContinuationOptions continuationOptions,
    TaskScheduler scheduler
)

Parameters

continuationFunction
Type: System..::.Func<(Of <( Task <(Of <( TResult >)>), TNewResult>)>)
A function to run when the Task<(Of <(TResult>)>) completes. When run, the delegate will be passed as an argument this completed task.
cancellationToken
Type: System.Threading..::.CancellationToken
The CancellationToken that will be assigned to the new task.
continuationOptions
Type: System.Threading.Tasks..::.TaskContinuationOptions
Options for when the continuation is scheduled and how it behaves. This includes criteria, such as OnlyOnCanceled, as well as execution options, such as ExecuteSynchronously.
scheduler
Type: System.Threading.Tasks..::.TaskScheduler
The TaskScheduler to associate with the continuation task and to use for its execution.

Type Parameters

TNewResult
The type of the result produced by the continuation.

Return Value

A new continuation Task<(Of <(TResult>)>).

Remarks

The returned Task<(Of <(TResult>)>) will not be scheduled for execution until the current task has completed, whether it completes due to running to completion successfully, faulting due to an unhandled exception, or exiting out early due to being canceled.

The continuationFunction, when executed, should return a Task<(Of <(TResult>)>). This task's completion state will be transferred to the task returned from the ContinueWith call.

Exceptions

Exception | Condition
System..::.ArgumentNullException | The continuationFunction argument is null.
System..::.ArgumentOutOfRangeException | The continuationOptions argument specifies an invalid value for TaskContinuationOptions.
System..::.ArgumentNullException | The scheduler argument is null.
System..::.ObjectDisposedException | The Task<(Of <(TResult>)>) has been disposed.
System..::.ObjectDisposedException | The provided CancellationToken has already been disposed.

See Also

Task<(Of <(TResult>)>) Class
ContinueWith Overload
System.Threading.Tasks Namespace


Dispose Method

[image] [image]

.NET Framework Class Library
Task<(Of <(TResult>)>)..::.Dispose Method
Task<(Of <(TResult>)>) Class See Also Send Feedback

Overload List

Name | Description
Dispose()()() | Disposes the Task, releasing all of its unmanaged resources. (Inherited from Task.)
Dispose(Boolean) | Disposes the Task, releasing all of its unmanaged resources. (Inherited from Task.)

See Also

Task<(Of <(TResult>)>) Class
System.Threading.Tasks Namespace


RunSynchronously Method

[image] [image]

.NET Framework Class Library
Task<(Of <(TResult>)>)..::.RunSynchronously Method
Task<(Of <(TResult>)>) Class See Also Send Feedback

Overload List

Name | Description
RunSynchronously()()() | Runs the Task synchronously on the current TaskScheduler. (Inherited from Task.)
RunSynchronously(TaskScheduler) | Runs the Task synchronously on the scheduler provided. (Inherited from Task.)

See Also

Task<(Of <(TResult>)>) Class
System.Threading.Tasks Namespace


Start Method

[image] [image]

.NET Framework Class Library
Task<(Of <(TResult>)>)..::.Start Method
Task<(Of <(TResult>)>) Class See Also Send Feedback

Overload List

Name | Description
Start()()() | Starts the Task, scheduling it for execution to the current TaskScheduler. (Inherited from Task.)
Start(TaskScheduler) | Starts the Task, scheduling it for execution to the specified TaskScheduler. (Inherited from Task.)

See Also

Task<(Of <(TResult>)>) Class
System.Threading.Tasks Namespace


Wait Method

[image] [image]

.NET Framework Class Library
Task<(Of <(TResult>)>)..::.Wait Method
Task<(Of <(TResult>)>) Class See Also Send Feedback

Overload List

Name | Description
Wait()()() | Waits for the Task to complete execution. (Inherited from Task.)
Wait(Int32) | Waits for the Task to complete execution. (Inherited from Task.)
Wait(CancellationToken) | Waits for the Task to complete execution. (Inherited from Task.)
Wait(TimeSpan) | Waits for the Task to complete execution. (Inherited from Task.)
Wait(Int32, CancellationToken) | Waits for the Task to complete execution. (Inherited from Task.)

See Also

Task<(Of <(TResult>)>) Class
System.Threading.Tasks Namespace


Task(TResult) Properties

[image] [image]

.NET Framework Class Library
Task<(Of <(TResult>)>) Properties
Task<(Of <(TResult>)>) Class See Also Send Feedback

The Task<(Of <(TResult>)>) type exposes the following members.

Properties

Name | Description
AsyncState | Gets the state object supplied when the Task was created, or null if none was supplied. (Inherited from Task.)
CreationOptions | Gets the TaskCreationOptions used to create this task. (Inherited from Task.)
Exception | Gets the Exception that caused the Task to end prematurely. If the Task completed successfully or has not yet thrown any exceptions, this will return null. (Inherited from Task.)
Factory | Provides access to factory methods for creating Task<(Of <(TResult>)>) instances.
Id | Gets a unique ID for this Task instance. (Inherited from Task.)
IsCanceled | Gets whether this Task instance has completed execution due to being canceled. (Inherited from Task.)
IsCompleted | Gets whether this Task has completed. (Inherited from Task.)
IsFaulted | Gets whether the Task completed due to an unhandled exception. (Inherited from Task.)
Result | Gets the result value of this Task<(Of <(TResult>)>).
Status | Gets the TaskStatus of this Task. (Inherited from Task.)

Explicit Interface Implementations

Name | Description
IAsyncResult..::.AsyncWaitHandle | Gets a WaitHandle that can be used to wait for the task to complete. (Inherited from Task.)
IAsyncResult..::.CompletedSynchronously | Gets an indication of whether the asynchronous operation completed synchronously. (Inherited from Task.)

See Also

Task<(Of <(TResult>)>) Class
System.Threading.Tasks Namespace


Factory Property

[image]

.NET Framework Class Library
Task<(Of <(TResult>)>)..::.Factory Property
Task<(Of <(TResult>)>) Class See Also Send Feedback

Provides access to factory methods for creating Task<(Of <(TResult>)>) instances.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared ReadOnly Property Factory As TaskFactory(Of TResult)
C#
public static TaskFactory<TResult> Factory { get; }

Remarks

The factory returned from Factory is a default instance of TaskFactory<(Of <(TResult>)>), as would result from using the default constructor on the factory type.

See Also

Task<(Of <(TResult>)>) Class
System.Threading.Tasks Namespace


Result Property

[image]

.NET Framework Class Library
Task<(Of <(TResult>)>)..::.Result Property
Task<(Of <(TResult>)>) Class See Also Send Feedback

Gets the result value of this Task<(Of <(TResult>)>).

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Property Result As TResult
C#
public TResult Result { get; internal set; }

Remarks

The get accessor for this property ensures that the asynchronous operation is complete before returning. Once the result of the computation is available, it is stored and will be returned immediately on later calls to Result.

See Also

Task<(Of <(TResult>)>) Class
System.Threading.Tasks Namespace


TaskCanceledException Class

[image]

.NET Framework Class Library
TaskCanceledException Class
See Also Send Feedback

Represents an exception used to communicate task cancellation.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
<SerializableAttribute> _
Public Class TaskCanceledException _
    Inherits OperationCanceledException
C#
[SerializableAttribute]
public class TaskCanceledException : OperationCanceledException

Inheritance Hierarchy

System..::.Object
System..::.Exception
System..::.SystemException
System..::.OperationCanceledException
System.Threading.Tasks..::.TaskCanceledException

See Also

System.Threading.Tasks Namespace


TaskCanceledException Constructor

[image] [image]

.NET Framework Class Library
TaskCanceledException Constructor
TaskCanceledException Class See Also Send Feedback

Overload List

Name | Description
TaskCanceledException()()() | Initializes a new instance of the TaskCanceledException class.
TaskCanceledException(String) | Initializes a new instance of the TaskCanceledException class with a specified error message.
TaskCanceledException(Task) | Initializes a new instance of the TaskCanceledException class with a reference to the Task that has been canceled.
TaskCanceledException(SerializationInfo, StreamingContext) | Initializes a new instance of the TaskCanceledException class with serialized data.
TaskCanceledException(String, Exception) | Initializes a new instance of the TaskCanceledException class with a specified error message and a reference to the inner exception that is the cause of this exception.

See Also

TaskCanceledException Class
System.Threading.Tasks Namespace


TaskCanceledException Constructor

[image]

.NET Framework Class Library
TaskCanceledException Constructor
TaskCanceledException Class See Also Send Feedback

Initializes a new instance of the TaskCanceledException class.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Sub New
C#
public TaskCanceledException()

See Also

TaskCanceledException Class
TaskCanceledException Overload
System.Threading.Tasks Namespace


TaskCanceledException Constructor (String)

[image]

.NET Framework Class Library
TaskCanceledException Constructor (String)
TaskCanceledException Class See Also Send Feedback

Initializes a new instance of the TaskCanceledException class with a specified error message.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Sub New ( _
    message As String _
)
C#
public TaskCanceledException(
    string message
)

Parameters

message
Type: System..::.String
The error message that explains the reason for the exception.

See Also

TaskCanceledException Class
TaskCanceledException Overload
System.Threading.Tasks Namespace


TaskCanceledException Constructor (Task)

[image]

.NET Framework Class Library
TaskCanceledException Constructor (Task)
TaskCanceledException Class See Also Send Feedback

Initializes a new instance of the TaskCanceledException class with a reference to the Task that has been canceled.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Sub New ( _
    task As Task _
)
C#
public TaskCanceledException(
    Task task
)

Parameters

task
Type: System.Threading.Tasks..::.Task
A task that has been canceled.

See Also

TaskCanceledException Class
TaskCanceledException Overload
System.Threading.Tasks Namespace


TaskCanceledException Constructor (SerializationInfo, StreamingContext)

[image]

.NET Framework Class Library
TaskCanceledException Constructor (SerializationInfo, StreamingContext)
TaskCanceledException Class See Also Send Feedback

Initializes a new instance of the TaskCanceledException class with serialized data.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Protected Sub New ( _
    info As SerializationInfo, _
    context As StreamingContext _
)
C#
protected TaskCanceledException(
    SerializationInfo info,
    StreamingContext context
)

Parameters

info
Type: System.Runtime.Serialization..::.SerializationInfo
The SerializationInfo that holds the serialized object data about the exception being thrown.
context
Type: System.Runtime.Serialization..::.StreamingContext
The StreamingContext that contains contextual information about the source or destination.

See Also

TaskCanceledException Class
TaskCanceledException Overload
System.Threading.Tasks Namespace


TaskCanceledException Constructor (String, Exception)

[image]

.NET Framework Class Library
TaskCanceledException Constructor (String, Exception)
TaskCanceledException Class See Also Send Feedback

Initializes a new instance of the TaskCanceledException class with a specified error message and a reference to the inner exception that is the cause of this exception.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Sub New ( _
    message As String, _
    innerException As Exception _
)
C#
public TaskCanceledException(
    string message,
    Exception innerException
)

Parameters

message
Type: System..::.String
The error message that explains the reason for the exception.
innerException
Type: System..::.Exception
The exception that is the cause of the current exception.

See Also

TaskCanceledException Class
TaskCanceledException Overload
System.Threading.Tasks Namespace


TaskCanceledException Methods

[image] [image]

.NET Framework Class Library
TaskCanceledException Methods
TaskCanceledException Class See Also Send Feedback

The TaskCanceledException type exposes the following members.

Methods

Name | Description
Equals | (Inherited from Object.)
Finalize | (Inherited from Object.)
GetBaseException | (Inherited from Exception.)
GetHashCode | (Inherited from Object.)
GetObjectData | (Inherited from Exception.)
GetType | (Inherited from Exception.)
MemberwiseClone | (Inherited from Object.)
ToString | (Inherited from Exception.)

See Also

TaskCanceledException Class
System.Threading.Tasks Namespace


TaskCanceledException Properties

[image] [image]

.NET Framework Class Library
TaskCanceledException Properties
TaskCanceledException Class See Also Send Feedback

The TaskCanceledException type exposes the following members.

Properties

Name | Description
Data | (Inherited from Exception.)
HelpLink | (Inherited from Exception.)
HResult | (Inherited from Exception.)
InnerException | (Inherited from Exception.)
Message | (Inherited from Exception.)
Source | (Inherited from Exception.)
StackTrace | (Inherited from Exception.)
TargetSite | (Inherited from Exception.)
Task | Gets the task associated with this exception.

See Also

TaskCanceledException Class
System.Threading.Tasks Namespace


Task Property

[image]

.NET Framework Class Library
TaskCanceledException..::.Task Property
TaskCanceledException Class See Also Send Feedback

Gets the task associated with this exception.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public ReadOnly Property Task As Task
C#
public Task Task { get; }

Remarks

It is permissible for no Task to be associated with a TaskCanceledException, in which case this property will return null.

See Also

TaskCanceledException Class
System.Threading.Tasks Namespace


TaskCompletionSource(TResult) Class

[image]

.NET Framework Class Library
TaskCompletionSource<(Of <(TResult>)>) Class
See Also Send Feedback

Represents the producer side of a Task<(Of <(TResult>)>) unbound to a delegate, providing access to the consumer side through the Task property.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
<HostProtectionAttribute(SecurityAction.LinkDemand, Synchronization := True,  _
    ExternalThreading := True)> _
Public Class TaskCompletionSource(Of TResult)
C#
[HostProtectionAttribute(SecurityAction.LinkDemand, Synchronization = true,
    ExternalThreading = true)]
public class TaskCompletionSource<TResult>

Type Parameters

TResult
The type of the result value assocatied with this TaskCompletionSource<(Of <(TResult>)>).

Remarks

It is often the case that a Task<(Of <(TResult>)>) is desired to represent another asynchronous operation. TaskCompletionSource is provided for this purpose. It enables the creation of a task that can be handed out to consumers, and those consumers can use the members of the task as they would any other. However, unlike most tasks, the state of a task created by a TaskCompletionSource is controlled explicitly by the methods on TaskCompletionSource. This enables the completion of the external asynchronous operation to be propagated to the underlying Task. The separation also ensures that consumers are not able to transition the state without access to the corresponding TaskCompletionSource.

All members of TaskCompletionSource<(Of <(TResult>)>) are thread-safe and may be used from multiple threads concurrently.

Inheritance Hierarchy

System..::.Object
System.Threading.Tasks..::.TaskCompletionSource<(Of <(TResult>)>)

See Also

System.Threading.Tasks Namespace


TaskCompletionSource(TResult) Constructor

[image] [image]

.NET Framework Class Library
TaskCompletionSource<(Of <(TResult>)>) Constructor
TaskCompletionSource<(Of <(TResult>)>) Class See Also Send Feedback

Overload List

Name | Description
TaskCompletionSource<(Of <(TResult>)>)()()() | Creates a TaskCompletionSource<(Of <(TResult>)>).
TaskCompletionSource<(Of <(TResult>)>)(Object) | Creates a TaskCompletionSource<(Of <(TResult>)>) with the specified state.
TaskCompletionSource<(Of <(TResult>)>)(TaskCreationOptions) | Creates a TaskCompletionSource<(Of <(TResult>)>) with the specified options.
TaskCompletionSource<(Of <(TResult>)>)(Object, TaskCreationOptions) | Creates a TaskCompletionSource<(Of <(TResult>)>) with the specified state and options.

See Also

TaskCompletionSource<(Of <(TResult>)>) Class
System.Threading.Tasks Namespace


TaskCompletionSource(TResult) Constructor

[image]

.NET Framework Class Library
TaskCompletionSource<(Of <(TResult>)>) Constructor
TaskCompletionSource<(Of <(TResult>)>) Class See Also Send Feedback

Creates a TaskCompletionSource<(Of <(TResult>)>).

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Sub New
C#
public TaskCompletionSource()

See Also

TaskCompletionSource<(Of <(TResult>)>) Class
TaskCompletionSource<(Of <(TResult>)>) Overload
System.Threading.Tasks Namespace


TaskCompletionSource(TResult) Constructor (Object)

[image]

.NET Framework Class Library
TaskCompletionSource<(Of <(TResult>)>) Constructor (Object)
TaskCompletionSource<(Of <(TResult>)>) Class See Also Send Feedback

Creates a TaskCompletionSource<(Of <(TResult>)>) with the specified state.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Sub New ( _
    state As Object _
)
C#
public TaskCompletionSource(
    Object state
)

Parameters

state
Type: System..::.Object
The state to use as the underlying Task<(Of <(TResult>)>)'s AsyncState.

See Also

TaskCompletionSource<(Of <(TResult>)>) Class
TaskCompletionSource<(Of <(TResult>)>) Overload
System.Threading.Tasks Namespace


TaskCompletionSource(TResult) Constructor (TaskCreationOptions)

[image]

.NET Framework Class Library
TaskCompletionSource<(Of <(TResult>)>) Constructor (TaskCreationOptions)
TaskCompletionSource<(Of <(TResult>)>) Class See Also Send Feedback

Creates a TaskCompletionSource<(Of <(TResult>)>) with the specified options.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Sub New ( _
    creationOptions As TaskCreationOptions _
)
C#
public TaskCompletionSource(
    TaskCreationOptions creationOptions
)

Parameters

creationOptions
Type: System.Threading.Tasks..::.TaskCreationOptions
The options to use when creating the underlying Task<(Of <(TResult>)>).

Remarks

The Task<(Of <(TResult>)>) created by this instance and accessible through its Task property will be instantiated using the specified creationOptions.

Exceptions

Exception | Condition
System..::.ArgumentOutOfRangeException | The creationOptions represent options invalid for use with a TaskCompletionSource<(Of <(TResult>)>).

See Also

TaskCompletionSource<(Of <(TResult>)>) Class
TaskCompletionSource<(Of <(TResult>)>) Overload
System.Threading.Tasks Namespace


TaskCompletionSource(TResult) Constructor (Object, TaskCreationOptions)

[image]

.NET Framework Class Library
TaskCompletionSource<(Of <(TResult>)>) Constructor (Object, TaskCreationOptions)
TaskCompletionSource<(Of <(TResult>)>) Class See Also Send Feedback

Creates a TaskCompletionSource<(Of <(TResult>)>) with the specified state and options.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Sub New ( _
    state As Object, _
    creationOptions As TaskCreationOptions _
)
C#
public TaskCompletionSource(
    Object state,
    TaskCreationOptions creationOptions
)

Parameters

state
Type: System..::.Object
The state to use as the underlying Task<(Of <(TResult>)>)'s AsyncState.
creationOptions
Type: System.Threading.Tasks..::.TaskCreationOptions
The options to use when creating the underlying Task<(Of <(TResult>)>).

Exceptions

Exception | Condition
System..::.ArgumentOutOfRangeException | The creationOptions represent options invalid for use with a TaskCompletionSource<(Of <(TResult>)>).

See Also

TaskCompletionSource<(Of <(TResult>)>) Class
TaskCompletionSource<(Of <(TResult>)>) Overload
System.Threading.Tasks Namespace


TaskCompletionSource(TResult) Methods

[image] [image]

.NET Framework Class Library
TaskCompletionSource<(Of <(TResult>)>) Methods
TaskCompletionSource<(Of <(TResult>)>) Class See Also Send Feedback

The TaskCompletionSource<(Of <(TResult>)>) type exposes the following members.

Methods

Name | Description
Equals | (Inherited from Object.)
Finalize | (Inherited from Object.)
GetHashCode | (Inherited from Object.)
GetType | (Inherited from Object.)
MemberwiseClone | (Inherited from Object.)
SetCanceled | Transitions the underlying Task<(Of <(TResult>)>) into the Canceled state.
SetException | Overloaded.
SetResult | Transitions the underlying Task<(Of <(TResult>)>) into the RanToCompletion state.
ToString | (Inherited from Object.)
TrySetCanceled | Attempts to transition the underlying Task<(Of <(TResult>)>) into the Canceled state.
TrySetException | Overloaded.
TrySetResult | Attempts to transition the underlying Task<(Of <(TResult>)>) into the RanToCompletion state.

See Also

TaskCompletionSource<(Of <(TResult>)>) Class
System.Threading.Tasks Namespace


SetCanceled Method

[image]

.NET Framework Class Library
TaskCompletionSource<(Of <(TResult>)>)..::.SetCanceled Method
TaskCompletionSource<(Of <(TResult>)>) Class See Also Send Feedback

Transitions the underlying Task<(Of <(TResult>)>) into the Canceled state.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Sub SetCanceled
C#
public void SetCanceled()

Exceptions

Exception | Condition
System..::.InvalidOperationException | The underlying Task<(Of <(TResult>)>) is already in one of the three final states: RanToCompletion, Faulted, or Canceled.
System..::.ObjectDisposedException | The Task was disposed.

See Also

TaskCompletionSource<(Of <(TResult>)>) Class
System.Threading.Tasks Namespace


SetException Method

[image] [image]

.NET Framework Class Library
TaskCompletionSource<(Of <(TResult>)>)..::.SetException Method
TaskCompletionSource<(Of <(TResult>)>) Class See Also Send Feedback

Overload List

Name | Description
SetException(IEnumerable<(Of <(Exception>)>)) | Transitions the underlying Task<(Of <(TResult>)>) into the Faulted state.
SetException(Exception) | Transitions the underlying Task<(Of <(TResult>)>) into the Faulted state.

See Also

TaskCompletionSource<(Of <(TResult>)>) Class
System.Threading.Tasks Namespace


SetException Method (IEnumerable(Exception))

[image]

.NET Framework Class Library
TaskCompletionSource<(Of <(TResult>)>)..::.SetException Method (IEnumerable<(Of <(Exception>)>))
TaskCompletionSource<(Of <(TResult>)>) Class See Also Send Feedback

Transitions the underlying Task<(Of <(TResult>)>) into the Faulted state.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Sub SetException ( _
    exceptions As IEnumerable(Of Exception) _
)
C#
public void SetException(
    IEnumerable<Exception> exceptions
)

Parameters

exceptions
Type: System.Collections.Generic..::.IEnumerable<(Of <(Exception>)>)
The collection of exceptions to bind to this Task<(Of <(TResult>)>).

Exceptions

Exception | Condition
System..::.ArgumentNullException | The exceptions argument is null.
System..::.ArgumentException | There are one or more null elements in exceptions.
System..::.InvalidOperationException | The underlying Task<(Of <(TResult>)>) is already in one of the three final states: RanToCompletion, Faulted, or Canceled.
System..::.ObjectDisposedException | The Task was disposed.

See Also

TaskCompletionSource<(Of <(TResult>)>) Class
SetException Overload
System.Threading.Tasks Namespace


SetException Method (Exception)

[image]

.NET Framework Class Library
TaskCompletionSource<(Of <(TResult>)>)..::.SetException Method (Exception)
TaskCompletionSource<(Of <(TResult>)>) Class See Also Send Feedback

Transitions the underlying Task<(Of <(TResult>)>) into the Faulted state.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Sub SetException ( _
    exception As Exception _
)
C#
public void SetException(
    Exception exception
)

Parameters

exception
Type: System..::.Exception
The exception to bind to this Task<(Of <(TResult>)>).

Exceptions

Exception | Condition
System..::.ArgumentNullException | The exception argument is null.
System..::.InvalidOperationException | The underlying Task<(Of <(TResult>)>) is already in one of the three final states: RanToCompletion, Faulted, or Canceled.
System..::.ObjectDisposedException | The Task was disposed.

See Also

TaskCompletionSource<(Of <(TResult>)>) Class
SetException Overload
System.Threading.Tasks Namespace


SetResult Method

[image]

.NET Framework Class Library
TaskCompletionSource<(Of <(TResult>)>)..::.SetResult Method
TaskCompletionSource<(Of <(TResult>)>) Class See Also Send Feedback

Transitions the underlying Task<(Of <(TResult>)>) into the RanToCompletion state.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Sub SetResult ( _
    result As TResult _
)
C#
public void SetResult(
    TResult result
)

Parameters

result
Type: TResult
The result value to bind to this Task<(Of <(TResult>)>).

Exceptions

Exception | Condition
System..::.InvalidOperationException | The underlying Task<(Of <(TResult>)>) is already in one of the three final states: RanToCompletion, Faulted, or Canceled.
System..::.ObjectDisposedException | The Task was disposed.

See Also

TaskCompletionSource<(Of <(TResult>)>) Class
System.Threading.Tasks Namespace


TrySetCanceled Method

[image]

.NET Framework Class Library
TaskCompletionSource<(Of <(TResult>)>)..::.TrySetCanceled Method
TaskCompletionSource<(Of <(TResult>)>) Class See Also Send Feedback

Attempts to transition the underlying Task<(Of <(TResult>)>) into the Canceled state.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Function TrySetCanceled As Boolean
C#
public bool TrySetCanceled()

Return Value

True if the operation was successful; otherwise, false.

Remarks

This operation will return false if the Task<(Of <(TResult>)>) is already in one of the three final states: RanToCompletion, Faulted, or Canceled.

Exceptions

Exception | Condition
System..::.ObjectDisposedException | The Task was disposed.

See Also

TaskCompletionSource<(Of <(TResult>)>) Class
System.Threading.Tasks Namespace


TrySetException Method

[image] [image]

.NET Framework Class Library
TaskCompletionSource<(Of <(TResult>)>)..::.TrySetException Method
TaskCompletionSource<(Of <(TResult>)>) Class See Also Send Feedback

Overload List

Name | Description
TrySetException(IEnumerable<(Of <(Exception>)>)) | Attempts to transition the underlying Task<(Of <(TResult>)>) into the Faulted state.
TrySetException(Exception) | Attempts to transition the underlying Task<(Of <(TResult>)>) into the Faulted state.

See Also

TaskCompletionSource<(Of <(TResult>)>) Class
System.Threading.Tasks Namespace


TrySetException Method (IEnumerable(Exception))

[image]

.NET Framework Class Library
TaskCompletionSource<(Of <(TResult>)>)..::.TrySetException Method (IEnumerable<(Of <(Exception>)>))
TaskCompletionSource<(Of <(TResult>)>) Class See Also Send Feedback

Attempts to transition the underlying Task<(Of <(TResult>)>) into the Faulted state.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Function TrySetException ( _
    exceptions As IEnumerable(Of Exception) _
) As Boolean
C#
public bool TrySetException(
    IEnumerable<Exception> exceptions
)

Parameters

exceptions
Type: System.Collections.Generic..::.IEnumerable<(Of <(Exception>)>)
The collection of exceptions to bind to this Task<(Of <(TResult>)>).

Return Value

True if the operation was successful; otherwise, false.

Remarks

This operation will return false if the Task<(Of <(TResult>)>) is already in one of the three final states: RanToCompletion, Faulted, or Canceled.

Exceptions

Exception | Condition
System..::.ArgumentNullException | The exceptions argument is null.
System..::.ArgumentException | There are one or more null elements in exceptions.
System..::.ArgumentException | The exceptions collection is empty.
System..::.ObjectDisposedException | The Task was disposed.

See Also

TaskCompletionSource<(Of <(TResult>)>) Class
TrySetException Overload
System.Threading.Tasks Namespace


TrySetException Method (Exception)

[image]

.NET Framework Class Library
TaskCompletionSource<(Of <(TResult>)>)..::.TrySetException Method (Exception)
TaskCompletionSource<(Of <(TResult>)>) Class See Also Send Feedback

Attempts to transition the underlying Task<(Of <(TResult>)>) into the Faulted state.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Function TrySetException ( _
    exception As Exception _
) As Boolean
C#
public bool TrySetException(
    Exception exception
)

Parameters

exception
Type: System..::.Exception
The exception to bind to this Task<(Of <(TResult>)>).

Return Value

True if the operation was successful; otherwise, false.

Remarks

This operation will return false if the Task<(Of <(TResult>)>) is already in one of the three final states: RanToCompletion, Faulted, or Canceled.

Exceptions

Exception | Condition
System..::.ArgumentNullException | The exception argument is null.
System..::.ObjectDisposedException | The Task was disposed.

See Also

TaskCompletionSource<(Of <(TResult>)>) Class
TrySetException Overload
System.Threading.Tasks Namespace


TrySetResult Method

[image]

.NET Framework Class Library
TaskCompletionSource<(Of <(TResult>)>)..::.TrySetResult Method
TaskCompletionSource<(Of <(TResult>)>) Class See Also Send Feedback

Attempts to transition the underlying Task<(Of <(TResult>)>) into the RanToCompletion state.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Function TrySetResult ( _
    result As TResult _
) As Boolean
C#
public bool TrySetResult(
    TResult result
)

Parameters

result
Type: TResult
The result value to bind to this Task<(Of <(TResult>)>).

Return Value

True if the operation was successful; otherwise, false.

Remarks

This operation will return false if the Task<(Of <(TResult>)>) is already in one of the three final states: RanToCompletion, Faulted, or Canceled.

Exceptions

Exception | Condition
System..::.ObjectDisposedException | The Task was disposed.

See Also

TaskCompletionSource<(Of <(TResult>)>) Class
System.Threading.Tasks Namespace


TaskCompletionSource(TResult) Properties

[image] [image]

.NET Framework Class Library
TaskCompletionSource<(Of <(TResult>)>) Properties
TaskCompletionSource<(Of <(TResult>)>) Class See Also Send Feedback

The TaskCompletionSource<(Of <(TResult>)>) type exposes the following members.

Properties

Name | Description
Task | Gets the Task<(Of <(TResult>)>) created by this TaskCompletionSource<(Of <(TResult>)>).

See Also

TaskCompletionSource<(Of <(TResult>)>) Class
System.Threading.Tasks Namespace


Task Property

[image]

.NET Framework Class Library
TaskCompletionSource<(Of <(TResult>)>)..::.Task Property
TaskCompletionSource<(Of <(TResult>)>) Class See Also Send Feedback

Gets the Task<(Of <(TResult>)>) created by this TaskCompletionSource<(Of <(TResult>)>).

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public ReadOnly Property Task As Task(Of TResult)
C#
public Task<TResult> Task { get; }

Remarks

This property enables a consumer access to the Task<(Of <(TResult>)>) that is controlled by this instance. The SetResult(TResult), SetException(Exception), SetException(IEnumerable<(Of <(Exception>)>)), and SetCanceled()()() methods (and their "Try" variants) on this instance all result in the relevant state transitions on this underlying Task.

See Also

TaskCompletionSource<(Of <(TResult>)>) Class
System.Threading.Tasks Namespace


TaskContinuationOptions Enumeration

[image]

.NET Framework Class Library
TaskContinuationOptions Enumeration
See Also Send Feedback

Specifies flags that control optional behavior for the creation and execution of continuation tasks.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
<SerializableAttribute> _
<FlagsAttribute> _
Public Enumeration TaskContinuationOptions
C#
[SerializableAttribute]
[FlagsAttribute]
public enum TaskContinuationOptions

Members

Member name | Description
None | Default = "Continue on any, no task options, run asynchronously" Specifies that the default behavior should be used. Continuations, by default, will be scheduled when the antecedent task completes, regardless of the task's final TaskStatus.
PreferFairness | A hint to a TaskScheduler to schedule a task in as fair a manner as possible, meaning that tasks scheduled sooner will be more likely to be run sooner, and tasks scheduled later will be more likely to be run later.
LongRunning | Specifies that a task will be a long-running, course-grained operation. It provides a hint to the TaskScheduler that oversubscription may be warranted.
AttachedToParent | Specifies that a task is attached to a parent in the task hierarchy.
NotOnRanToCompletion | Specifies that the continuation task should not be scheduled if its antecedent ran to completion. This option is not valid for multi-task continuations.
NotOnFaulted | Specifies that the continuation task should not be scheduled if its antecedent threw an unhandled exception. This option is not valid for multi-task continuations.
NotOnCanceled | Specifies that the continuation task should not be scheduled if its antecedent was canceled. This option is not valid for multi-task continuations.
OnlyOnRanToCompletion | Specifies that the continuation task should be scheduled only if its antecedent ran to completion. This option is not valid for multi-task continuations.
OnlyOnFaulted | Specifies that the continuation task should be scheduled only if its antecedent threw an unhandled exception. This option is not valid for multi-task continuations.
OnlyOnCanceled | Specifies that the continuation task should be scheduled only if its antecedent was canceled. This option is not valid for multi-task continuations.
ExecuteSynchronously | Specifies that the continuation task should be executed synchronously. With this option specified, the continuation will be run on the same thread that causes the antecedent task to transition into its final state. If the antecedent is already complete when the continuation is created, the continuation will run on the thread creating the continuation. Only very short-running continuations should be executed synchronously.

See Also

System.Threading.Tasks Namespace


TaskCreationOptions Enumeration

[image]

.NET Framework Class Library
TaskCreationOptions Enumeration
See Also Send Feedback

Specifies flags that control optional behavior for the creation and execution of tasks.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
<SerializableAttribute> _
<FlagsAttribute> _
Public Enumeration TaskCreationOptions
C#
[SerializableAttribute]
[FlagsAttribute]
public enum TaskCreationOptions

Members

Member name | Description
None | Specifies that the default behavior should be used.
PreferFairness | A hint to a TaskScheduler to schedule a task in as fair a manner as possible, meaning that tasks scheduled sooner will be more likely to be run sooner, and tasks scheduled later will be more likely to be run later.
LongRunning | Specifies that a task will be a long-running, course-grained operation. It provides a hint to the TaskScheduler that oversubscription may be warranted.
AttachedToParent | Specifies that a task is attached to a parent in the task hierarchy.

See Also

System.Threading.Tasks Namespace


TaskExtensions Class

[image]

.NET Framework Class Library
TaskExtensions Class
See Also Send Feedback

Provides a set of static (Shared in Visual Basic) methods for working with specific kinds of Task instances.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public NotInheritable Class TaskExtensions
C#
public static class TaskExtensions

Inheritance Hierarchy

System..::.Object
System.Threading.Tasks..::.TaskExtensions

See Also

System.Threading.Tasks Namespace


TaskExtensions Methods

[image] [image]

.NET Framework Class Library
TaskExtensions Methods
TaskExtensions Class See Also Send Feedback

Methods

Name | Description
Unwrap | Overloaded.

See Also

TaskExtensions Class
System.Threading.Tasks Namespace


Unwrap Method

[image] [image]

.NET Framework Class Library
TaskExtensions..::.Unwrap Method
TaskExtensions Class See Also Send Feedback

Overload List

Name | Description
Unwrap<(Of <(TResult>)>)(Task<(Of <(Task<(Of <(TResult>)>)>)>)) | Creates a proxy Task{TResult} that represents the asynchronous operation of a Task{Task{TResult}}.
Unwrap(Task<(Of <(Task>)>)) | Creates a proxy Task that represents the asynchronous operation of a Task{Task}.

See Also

TaskExtensions Class
System.Threading.Tasks Namespace


Unwrap(TResult) Method (Task(Task(TResult)))

[image]

.NET Framework Class Library
TaskExtensions..::.Unwrap<(Of <(TResult>)>) Method (Task<(Of <(Task<(Of <(TResult>)>)>)>))
TaskExtensions Class See Also Send Feedback

Creates a proxy Task{TResult} that represents the asynchronous operation of a Task{Task{TResult}}.
Unwraps a Task that returns another Task.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function Unwrap(Of TResult) ( _
    task As Task(Of Task(Of TResult)) _
) As Task(Of TResult)
C#
public static Task<TResult> Unwrap<TResult>(
    Task<Task<TResult>> task
)

Parameters

task
Type: System.Threading.Tasks..::.Task <(Of <( Task <(Of <(TResult>)>)>)>)
The Task{Task{TResult}} to unwrap.

Type Parameters

TResult

Return Value

A Task{TResult} that represents the asynchronous operation of the provided Task{Task{TResult}}.

Remarks

It is often useful to be able to return a Task{TResult} from a Task{TResult}, where the inner Task{TResult} represents work done as part of the outer Task{TResult}. However, doing so results in a Task{Task{TResult}}, which, if not dealt with carefully, could produce unexpected behavior. Unwrap solves this problem by creating a proxy Task{TResult} that represents the entire asynchronous operation of such a Task{Task{TResult}}.

Exceptions

Exception | Condition
System..::.ArgumentNullException | The exception that is thrown if the task argument is null.

See Also

TaskExtensions Class
Unwrap Overload
System.Threading.Tasks Namespace


Unwrap Method (Task(Task))

[image]

.NET Framework Class Library
TaskExtensions..::.Unwrap Method (Task<(Of <(Task>)>))
TaskExtensions Class See Also Send Feedback

Creates a proxy Task that represents the asynchronous operation of a Task{Task}.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function Unwrap ( _
    task As Task(Of Task) _
) As Task
C#
public static Task Unwrap(
    Task<Task> task
)

Parameters

task
Type: System.Threading.Tasks..::.Task <(Of <( Task >)>)
The Task{Task} to unwrap.

Return Value

A Task that represents the asynchronous operation of the provided Task{Task}.

Remarks

It is often useful to be able to return a Task from a Task{TResult}, where the inner Task represents work done as part of the outer Task{TResult}. However, doing so results in a Task{Task}, which, if not dealt with carefully, could produce unexpected behavior. Unwrap solves this problem by creating a proxy Task that represents the entire asynchronous operation of such a Task{Task}.

Exceptions

Exception | Condition
System..::.ArgumentNullException | The exception that is thrown if the task argument is null.

See Also

TaskExtensions Class
Unwrap Overload
System.Threading.Tasks Namespace


TaskFactory Class

[image]

.NET Framework Class Library
TaskFactory Class
See Also Send Feedback

Provides support for creating and scheduling Tasks.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
<HostProtectionAttribute(SecurityAction.LinkDemand, Synchronization := True,  _
    ExternalThreading := True)> _
Public Class TaskFactory
C#
[HostProtectionAttribute(SecurityAction.LinkDemand, Synchronization = true,
    ExternalThreading = true)]
public class TaskFactory

Remarks

There are many common patterns for which tasks are relevant. The TaskFactory class encodes some of these patterns into methods that pick up default settings, which are configurable through its constructors.

A default instance of TaskFactory is available through the Task.Factory property.

Inheritance Hierarchy

System..::.Object
System.Threading.Tasks..::.TaskFactory

See Also

System.Threading.Tasks Namespace


TaskFactory Constructor

[image] [image]

.NET Framework Class Library
TaskFactory Constructor
TaskFactory Class See Also Send Feedback

Overload List

Name | Description
TaskFactory()()() | Initializes a TaskFactory instance with the default configuration.
TaskFactory(CancellationToken) | Initializes a TaskFactory instance with the specified configuration.
TaskFactory(TaskScheduler) | Initializes a TaskFactory instance with the specified configuration.
TaskFactory(TaskCreationOptions, TaskContinuationOptions) | Initializes a TaskFactory instance with the specified configuration.
TaskFactory(CancellationToken, TaskCreationOptions, TaskContinuationOptions, TaskScheduler) | Initializes a TaskFactory instance with the specified configuration.

See Also

TaskFactory Class
System.Threading.Tasks Namespace


TaskFactory Constructor

[image]

.NET Framework Class Library
TaskFactory Constructor
TaskFactory Class See Also Send Feedback

Initializes a TaskFactory instance with the default configuration.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Sub New
C#
public TaskFactory()

Remarks

This constructor creates a TaskFactory instance with a default configuration. The TaskCreationOptions property is initialized to TaskCreationOptions.None, the TaskContinuationOptions property is initialized to TaskContinuationOptions.None, and the TaskScheduler property is initialized to the current scheduler (see TaskScheduler.Current).

See Also

TaskFactory Class
TaskFactory Overload
System.Threading.Tasks Namespace


TaskFactory Constructor (CancellationToken)

[image]

.NET Framework Class Library
TaskFactory Constructor (CancellationToken)
TaskFactory Class See Also Send Feedback

Initializes a TaskFactory instance with the specified configuration.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Sub New ( _
    cancellationToken As CancellationToken _
)
C#
public TaskFactory(
    CancellationToken cancellationToken
)

Parameters

cancellationToken
Type: System.Threading..::.CancellationToken
The default CancellationToken that will be assigned to tasks created by this TaskFactory unless another CancellationToken is explicitly specified while calling the factory methods.

Remarks

This constructor creates a TaskFactory instance with a default configuration. The TaskCreationOptions property is initialized to TaskCreationOptions.None, the TaskContinuationOptions property is initialized to TaskContinuationOptions.None, and the TaskScheduler property is initialized to the current scheduler (see TaskScheduler.Current).

See Also

TaskFactory Class
TaskFactory Overload
System.Threading.Tasks Namespace


TaskFactory Constructor (TaskScheduler)

[image]

.NET Framework Class Library
TaskFactory Constructor (TaskScheduler)
TaskFactory Class See Also Send Feedback

Initializes a TaskFactory instance with the specified configuration.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Sub New ( _
    scheduler As TaskScheduler _
)
C#
public TaskFactory(
    TaskScheduler scheduler
)

Parameters

scheduler
Type: System.Threading.Tasks..::.TaskScheduler
The TaskScheduler to use to schedule any tasks created with this TaskFactory. A null value indicates that the current TaskScheduler should be used.

Remarks

With this constructor, the TaskCreationOptions property is initialized to TaskCreationOptions.None, the TaskContinuationOptions property is initialized to TaskContinuationOptions.None, and the TaskScheduler property is initialized to scheduler, unless it's null, in which case the property is initialized to the current scheduler (see TaskScheduler.Current).

See Also

TaskFactory Class
TaskFactory Overload
System.Threading.Tasks Namespace


TaskFactory Constructor (TaskCreationOptions, TaskContinuationOptions)

[image]

.NET Framework Class Library
TaskFactory Constructor (TaskCreationOptions, TaskContinuationOptions)
TaskFactory Class See Also Send Feedback

Initializes a TaskFactory instance with the specified configuration.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Sub New ( _
    creationOptions As TaskCreationOptions, _
    continuationOptions As TaskContinuationOptions _
)
C#
public TaskFactory(
    TaskCreationOptions creationOptions,
    TaskContinuationOptions continuationOptions
)

Parameters

creationOptions
Type: System.Threading.Tasks..::.TaskCreationOptions
The default TaskCreationOptions to use when creating tasks with this TaskFactory.
continuationOptions
Type: System.Threading.Tasks..::.TaskContinuationOptions
The default TaskContinuationOptions to use when creating continuation tasks with this TaskFactory.

Remarks

With this constructor, the TaskCreationOptions property is initialized to creationOptions, the TaskContinuationOptions property is initialized to continuationOptions, and the TaskScheduler property is initialized to the current scheduler (see TaskScheduler.Current).

Exceptions

Exception | Condition
System..::.ArgumentOutOfRangeException | The exception that is thrown when the creationOptions argument or the continuationOptions argument specifies an invalid value.

See Also

TaskFactory Class
TaskFactory Overload
System.Threading.Tasks Namespace


TaskFactory Constructor (CancellationToken, TaskCreationOptions, TaskContinuationOptions, TaskScheduler)

[image]

.NET Framework Class Library
TaskFactory Constructor (CancellationToken, TaskCreationOptions, TaskContinuationOptions, TaskScheduler)
TaskFactory Class See Also Send Feedback

Initializes a TaskFactory instance with the specified configuration.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Sub New ( _
    cancellationToken As CancellationToken, _
    creationOptions As TaskCreationOptions, _
    continuationOptions As TaskContinuationOptions, _
    scheduler As TaskScheduler _
)
C#
public TaskFactory(
    CancellationToken cancellationToken,
    TaskCreationOptions creationOptions,
    TaskContinuationOptions continuationOptions,
    TaskScheduler scheduler
)

Parameters

cancellationToken
Type: System.Threading..::.CancellationToken
The default CancellationToken that will be assigned to tasks created by this TaskFactory unless another CancellationToken is explicitly specified while calling the factory methods.
creationOptions
Type: System.Threading.Tasks..::.TaskCreationOptions
The default TaskCreationOptions to use when creating tasks with this TaskFactory.
continuationOptions
Type: System.Threading.Tasks..::.TaskContinuationOptions
The default TaskContinuationOptions to use when creating continuation tasks with this TaskFactory.
scheduler
Type: System.Threading.Tasks..::.TaskScheduler
The default TaskScheduler to use to schedule any Tasks created with this TaskFactory. A null value indicates that TaskScheduler.Current should be used.

Remarks

With this constructor, the TaskCreationOptions property is initialized to creationOptions, the TaskContinuationOptions property is initialized to continuationOptions, and the TaskScheduler property is initialized to scheduler, unless it's null, in which case the property is initialized to the current scheduler (see TaskScheduler.Current).

Exceptions

Exception | Condition
System..::.ArgumentOutOfRangeException | The exception that is thrown when the creationOptions argument or the continuationOptions argumentspecifies an invalid value.

See Also

TaskFactory Class
TaskFactory Overload
System.Threading.Tasks Namespace


TaskFactory Methods

[image] [image]

.NET Framework Class Library
TaskFactory Methods
TaskFactory Class See Also Send Feedback

The TaskFactory type exposes the following members.

Methods

Name | Description
ContinueWhenAll | Overloaded.
ContinueWhenAny | Overloaded.
Equals | (Inherited from Object.)
Finalize | (Inherited from Object.)
FromAsync | Overloaded.
GetHashCode | (Inherited from Object.)
GetType | (Inherited from Object.)
MemberwiseClone | (Inherited from Object.)
StartNew | Overloaded.
ToString | (Inherited from Object.)

See Also

TaskFactory Class
System.Threading.Tasks Namespace


ContinueWhenAll Method

[image] [image]

.NET Framework Class Library
TaskFactory..::.ContinueWhenAll Method
TaskFactory Class See Also Send Feedback

Overload List

Name | Description
ContinueWhenAll(array<Task>[]()[], Action<(Of <(array<Task>[]()[]>)>)) | Creates a continuation Task that will be started upon the completion of a set of provided Tasks.
ContinueWhenAll<(Of <(TResult>)>)(array<Task>[]()[], Func<(Of <(array<Task>[]()[], TResult>)>)) | Creates a continuation Task that will be started upon the completion of a set of provided Tasks.
ContinueWhenAll<(Of <(TAntecedentResult>)>)(array<Task<(Of <(TAntecedentResult>)>)>[]()[], Action<(Of <(array<Task<(Of <(TAntecedentResult>)>)>[]()[]>)>)) | Creates a continuation Task that will be started upon the completion of a set of provided Tasks.
ContinueWhenAll<(Of <(TAntecedentResult, TResult>)>)(array<Task<(Of <(TAntecedentResult>)>)>[]()[], Func<(Of <(array<Task<(Of <(TAntecedentResult>)>)>[]()[], TResult>)>)) | Creates a continuation Task that will be started upon the completion of a set of provided Tasks.
ContinueWhenAll(array<Task>[]()[], Action<(Of <(array<Task>[]()[]>)>), CancellationToken) | Creates a continuation Task that will be started upon the completion of a set of provided Tasks.
ContinueWhenAll(array<Task>[]()[], Action<(Of <(array<Task>[]()[]>)>), TaskContinuationOptions) | Creates a continuation Task that will be started upon the completion of a set of provided Tasks.
ContinueWhenAll<(Of <(TResult>)>)(array<Task>[]()[], Func<(Of <(array<Task>[]()[], TResult>)>), CancellationToken) | Creates a continuation Task that will be started upon the completion of a set of provided Tasks.
ContinueWhenAll<(Of <(TResult>)>)(array<Task>[]()[], Func<(Of <(array<Task>[]()[], TResult>)>), TaskContinuationOptions) | Creates a continuation Task that will be started upon the completion of a set of provided Tasks.
ContinueWhenAll<(Of <(TAntecedentResult>)>)(array<Task<(Of <(TAntecedentResult>)>)>[]()[], Action<(Of <(array<Task<(Of <(TAntecedentResult>)>)>[]()[]>)>), CancellationToken) | Creates a continuation Task that will be started upon the completion of a set of provided Tasks.
ContinueWhenAll<(Of <(TAntecedentResult>)>)(array<Task<(Of <(TAntecedentResult>)>)>[]()[], Action<(Of <(array<Task<(Of <(TAntecedentResult>)>)>[]()[]>)>), TaskContinuationOptions) | Creates a continuation Task that will be started upon the completion of a set of provided Tasks.
ContinueWhenAll<(Of <(TAntecedentResult, TResult>)>)(array<Task<(Of <(TAntecedentResult>)>)>[]()[], Func<(Of <(array<Task<(Of <(TAntecedentResult>)>)>[]()[], TResult>)>), CancellationToken) | Creates a continuation Task that will be started upon the completion of a set of provided Tasks.
ContinueWhenAll<(Of <(TAntecedentResult, TResult>)>)(array<Task<(Of <(TAntecedentResult>)>)>[]()[], Func<(Of <(array<Task<(Of <(TAntecedentResult>)>)>[]()[], TResult>)>), TaskContinuationOptions) | Creates a continuation Task that will be started upon the completion of a set of provided Tasks.
ContinueWhenAll(array<Task>[]()[], Action<(Of <(array<Task>[]()[]>)>), CancellationToken, TaskContinuationOptions, TaskScheduler) | Creates a continuation Task that will be started upon the completion of a set of provided Tasks.
ContinueWhenAll<(Of <(TResult>)>)(array<Task>[]()[], Func<(Of <(array<Task>[]()[], TResult>)>), CancellationToken, TaskContinuationOptions, TaskScheduler) | Creates a continuation Task that will be started upon the completion of a set of provided Tasks.
ContinueWhenAll<(Of <(TAntecedentResult>)>)(array<Task<(Of <(TAntecedentResult>)>)>[]()[], Action<(Of <(array<Task<(Of <(TAntecedentResult>)>)>[]()[]>)>), CancellationToken, TaskContinuationOptions, TaskScheduler) | Creates a continuation Task that will be started upon the completion of a set of provided Tasks.
ContinueWhenAll<(Of <(TAntecedentResult, TResult>)>)(array<Task<(Of <(TAntecedentResult>)>)>[]()[], Func<(Of <(array<Task<(Of <(TAntecedentResult>)>)>[]()[], TResult>)>), CancellationToken, TaskContinuationOptions, TaskScheduler) | Creates a continuation Task that will be started upon the completion of a set of provided Tasks.

See Also

TaskFactory Class
System.Threading.Tasks Namespace


ContinueWhenAll Method (Task[], Action(Task[]))

[image]

.NET Framework Class Library
TaskFactory..::.ContinueWhenAll Method (array<Task>[]()[], Action<(Of <(array<Task>[]()[]>)>))
TaskFactory Class See Also Send Feedback

Creates a continuation Task that will be started upon the completion of a set of provided Tasks.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Function ContinueWhenAll ( _
    tasks As Task(), _
    continuationAction As Action(Of Task()) _
) As Task
C#
public Task ContinueWhenAll(
    Task[] tasks,
    Action<Task[]> continuationAction
)

Parameters

tasks
Type: array< System.Threading.Tasks..::.Task >[]()[]
The array of tasks from which to continue.
continuationAction
Type: System..::.Action<(Of <(array< Task >[]()[]>)>)
The action delegate to execute when all tasks in the tasks array have completed.

Return Value

The new continuation Task.

Exceptions

Exception | Condition
System..::.ArgumentNullException | The exception that is thrown when the tasks array is null.
System..::.ArgumentNullException | The exception that is thrown when the continuationAction argument is null.
System..::.ArgumentException | The exception that is thrown when the tasks array contains a null value.
System..::.ArgumentException | The exception that is thrown when the tasks array is empty.
System..::.ObjectDisposedException | The exception that is thrown when one of the elements in the tasks array has been disposed.

See Also

TaskFactory Class
ContinueWhenAll Overload
System.Threading.Tasks Namespace


ContinueWhenAll(TResult) Method (Task[], Func(Task[], TResult))

[image]

.NET Framework Class Library
TaskFactory..::.ContinueWhenAll<(Of <(TResult>)>) Method (array<Task>[]()[], Func<(Of <(array<Task>[]()[], TResult>)>))
TaskFactory Class See Also Send Feedback

Creates a continuation Task that will be started upon the completion of a set of provided Tasks.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Function ContinueWhenAll(Of TResult) ( _
    tasks As Task(), _
    continuationFunction As Func(Of Task(), TResult) _
) As Task(Of TResult)
C#
public Task<TResult> ContinueWhenAll<TResult>(
    Task[] tasks,
    Func<Task[], TResult> continuationFunction
)

Parameters

tasks
Type: array< System.Threading.Tasks..::.Task >[]()[]
The array of tasks from which to continue.
continuationFunction
Type: System..::.Func<(Of <(array< Task >[]()[], TResult>)>)
The function delegate to execute when all tasks in the tasks array have completed.

Type Parameters

TResult
The type of the result that is returned by the continuationFunction delegate and associated with the created Task<(Of <(TResult>)>).

Return Value

The new continuation Task<(Of <(TResult>)>).

Exceptions

Exception | Condition
System..::.ArgumentNullException | The exception that is thrown when the tasks array is null.
System..::.ArgumentNullException | The exception that is thrown when the continuationFunction argument is null.
System..::.ArgumentException | The exception that is thrown when the tasks array contains a null value.
System..::.ArgumentException | The exception that is thrown when the tasks array is empty.
System..::.ObjectDisposedException | The exception that is thrown when one of the elements in the tasks array has been disposed.

See Also

TaskFactory Class
ContinueWhenAll Overload
System.Threading.Tasks Namespace


ContinueWhenAll(TAntecedentResult) Method (Task(TAntecedentResult)[], Action(Task(TAntecedentResult)[]))

[image]

.NET Framework Class Library
TaskFactory..::.ContinueWhenAll<(Of <(TAntecedentResult>)>) Method (array<Task<(Of <(TAntecedentResult>)>)>[]()[], Action<(Of <(array<Task<(Of <(TAntecedentResult>)>)>[]()[]>)>))
TaskFactory Class See Also Send Feedback

Creates a continuation Task that will be started upon the completion of a set of provided Tasks.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Function ContinueWhenAll(Of TAntecedentResult) ( _
    tasks As Task(Of TAntecedentResult)(), _
    continuationAction As Action(Of Task(Of TAntecedentResult)()) _
) As Task
C#
public Task ContinueWhenAll<TAntecedentResult>(
    Task<TAntecedentResult>[] tasks,
    Action<Task<TAntecedentResult>[]> continuationAction
)

Parameters

tasks
Type: array< System.Threading.Tasks..::.Task <(Of <(TAntecedentResult>)>) >[]()[]
The array of tasks from which to continue.
continuationAction
Type: System..::.Action<(Of <(array< Task <(Of <(TAntecedentResult>)>) >[]()[]>)>)
The action delegate to execute when all tasks in the tasks array have completed.

Type Parameters

TAntecedentResult
The type of the result of the antecedent tasks.

Return Value

The new continuation Task.

Exceptions

Exception | Condition
System..::.ArgumentNullException | The exception that is thrown when the tasks array is null.
System..::.ArgumentNullException | The exception that is thrown when the continuationAction argument is null.
System..::.ArgumentException | The exception that is thrown when the tasks array contains a null value.
System..::.ArgumentException | The exception that is thrown when the tasks array is empty.
System..::.ObjectDisposedException | The exception that is thrown when one of the elements in the tasks array has been disposed.

See Also

TaskFactory Class
ContinueWhenAll Overload
System.Threading.Tasks Namespace


ContinueWhenAll(TAntecedentResult, TResult) Method (Task(TAntecedentResult)[], Func(Task(TAntecedentResult)[], TResult))

[image]

.NET Framework Class Library
TaskFactory..::.ContinueWhenAll<(Of <(TAntecedentResult, TResult>)>) Method (array<Task<(Of <(TAntecedentResult>)>)>[]()[], Func<(Of <(array<Task<(Of <(TAntecedentResult>)>)>[]()[], TResult>)>))
TaskFactory Class See Also Send Feedback

Creates a continuation Task that will be started upon the completion of a set of provided Tasks.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Function ContinueWhenAll(Of TAntecedentResult, TResult) ( _
    tasks As Task(Of TAntecedentResult)(), _
    continuationFunction As Func(Of Task(Of TAntecedentResult)(), TResult) _
) As Task(Of TResult)
C#
public Task<TResult> ContinueWhenAll<TAntecedentResult, TResult>(
    Task<TAntecedentResult>[] tasks,
    Func<Task<TAntecedentResult>[], TResult> continuationFunction
)

Parameters

tasks
Type: array< System.Threading.Tasks..::.Task <(Of <(TAntecedentResult>)>) >[]()[]
The array of tasks from which to continue.
continuationFunction
Type: System..::.Func<(Of <(array< Task <(Of <(TAntecedentResult>)>) >[]()[], TResult>)>)
The function delegate to execute when all tasks in the tasks array have completed.

Type Parameters

TAntecedentResult
The type of the result of the antecedent tasks.
TResult
The type of the result that is returned by the continuationFunction delegate and associated with the created Task<(Of <(TResult>)>).

Return Value

The new continuation Task<(Of <(TResult>)>).

Exceptions

Exception | Condition
System..::.ArgumentNullException | The exception that is thrown when the tasks array is null.
System..::.ArgumentNullException | The exception that is thrown when the continuationFunction argument is null.
System..::.ArgumentException | The exception that is thrown when the tasks array contains a null value.
System..::.ArgumentException | The exception that is thrown when the tasks array is empty.
System..::.ObjectDisposedException | The exception that is thrown when one of the elements in the tasks array has been disposed.

See Also

TaskFactory Class
ContinueWhenAll Overload
System.Threading.Tasks Namespace


ContinueWhenAll Method (Task[], Action(Task[]), CancellationToken)

[image]

.NET Framework Class Library
TaskFactory..::.ContinueWhenAll Method (array<Task>[]()[], Action<(Of <(array<Task>[]()[]>)>), CancellationToken)
TaskFactory Class See Also Send Feedback

Creates a continuation Task that will be started upon the completion of a set of provided Tasks.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Function ContinueWhenAll ( _
    tasks As Task(), _
    continuationAction As Action(Of Task()), _
    cancellationToken As CancellationToken _
) As Task
C#
public Task ContinueWhenAll(
    Task[] tasks,
    Action<Task[]> continuationAction,
    CancellationToken cancellationToken
)

Parameters

tasks
Type: array< System.Threading.Tasks..::.Task >[]()[]
The array of tasks from which to continue.
continuationAction
Type: System..::.Action<(Of <(array< Task >[]()[]>)>)
The action delegate to execute when all tasks in the tasks array have completed.
cancellationToken
Type: System.Threading..::.CancellationToken
The CancellationToken that will be assigned to the new continuation task.

Return Value

The new continuation Task.

Exceptions

Exception | Condition
System..::.ArgumentNullException | The exception that is thrown when the tasks array is null.
System..::.ArgumentNullException | The exception that is thrown when the continuationAction argument is null.
System..::.ArgumentException | The exception that is thrown when the tasks array contains a null value.
System..::.ArgumentException | The exception that is thrown when the tasks array is empty.
System..::.ObjectDisposedException | The exception that is thrown when one of the elements in the tasks array has been disposed.
System..::.ObjectDisposedException | The provided CancellationToken has already been disposed.

See Also

TaskFactory Class
ContinueWhenAll Overload
System.Threading.Tasks Namespace


ContinueWhenAll Method (Task[], Action(Task[]), TaskContinuationOptions)

[image]

.NET Framework Class Library
TaskFactory..::.ContinueWhenAll Method (array<Task>[]()[], Action<(Of <(array<Task>[]()[]>)>), TaskContinuationOptions)
TaskFactory Class See Also Send Feedback

Creates a continuation Task that will be started upon the completion of a set of provided Tasks.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Function ContinueWhenAll ( _
    tasks As Task(), _
    continuationAction As Action(Of Task()), _
    continuationOptions As TaskContinuationOptions _
) As Task
C#
public Task ContinueWhenAll(
    Task[] tasks,
    Action<Task[]> continuationAction,
    TaskContinuationOptions continuationOptions
)

Parameters

tasks
Type: array< System.Threading.Tasks..::.Task >[]()[]
The array of tasks from which to continue.
continuationAction
Type: System..::.Action<(Of <(array< Task >[]()[]>)>)
The action delegate to execute when all tasks in the tasks array have completed.
continuationOptions
Type: System.Threading.Tasks..::.TaskContinuationOptions
The TaskContinuationOptions value that controls the behavior of the created continuation Task.

Return Value

The new continuation Task.

Remarks

The NotOn* and OnlyOn* TaskContinuationOptions, which constrain for which TaskStatus states a continuation will be executed, are illegal with ContinueWhenAll.

Exceptions

Exception | Condition
System..::.ArgumentNullException | The exception that is thrown when the tasks array is null.
System..::.ArgumentNullException | The exception that is thrown when the continuationAction argument is null.
System..::.ArgumentException | The exception that is thrown when the tasks array contains a null value.
System..::.ArgumentException | The exception that is thrown when the tasks array is empty.
System..::.ArgumentOutOfRangeException | The exception that is thrown when the continuationOptions argument specifies an invalid TaskContinuationOptions value.
System..::.ObjectDisposedException | The exception that is thrown when one of the elements in the tasks array has been disposed.

See Also

TaskFactory Class
ContinueWhenAll Overload
System.Threading.Tasks Namespace


ContinueWhenAll(TResult) Method (Task[], Func(Task[], TResult), CancellationToken)

[image]

.NET Framework Class Library
TaskFactory..::.ContinueWhenAll<(Of <(TResult>)>) Method (array<Task>[]()[], Func<(Of <(array<Task>[]()[], TResult>)>), CancellationToken)
TaskFactory Class See Also Send Feedback

Creates a continuation Task that will be started upon the completion of a set of provided Tasks.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Function ContinueWhenAll(Of TResult) ( _
    tasks As Task(), _
    continuationFunction As Func(Of Task(), TResult), _
    cancellationToken As CancellationToken _
) As Task(Of TResult)
C#
public Task<TResult> ContinueWhenAll<TResult>(
    Task[] tasks,
    Func<Task[], TResult> continuationFunction,
    CancellationToken cancellationToken
)

Parameters

tasks
Type: array< System.Threading.Tasks..::.Task >[]()[]
The array of tasks from which to continue.
continuationFunction
Type: System..::.Func<(Of <(array< Task >[]()[], TResult>)>)
The function delegate to execute when all tasks in the tasks array have completed.
cancellationToken
Type: System.Threading..::.CancellationToken
The CancellationToken that will be assigned to the new continuation task.

Type Parameters

TResult
The type of the result that is returned by the continuationFunction delegate and associated with the created Task<(Of <(TResult>)>).

Return Value

The new continuation Task<(Of <(TResult>)>).

Exceptions

Exception | Condition
System..::.ArgumentNullException | The exception that is thrown when the tasks array is null.
System..::.ArgumentNullException | The exception that is thrown when the continuationFunction argument is null.
System..::.ArgumentException | The exception that is thrown when the tasks array contains a null value.
System..::.ArgumentException | The exception that is thrown when the tasks array is empty.
System..::.ObjectDisposedException | The exception that is thrown when one of the elements in the tasks array has been disposed.
System..::.ObjectDisposedException | The provided CancellationToken has already been disposed.

See Also

TaskFactory Class
ContinueWhenAll Overload
System.Threading.Tasks Namespace


ContinueWhenAll(TResult) Method (Task[], Func(Task[], TResult), TaskContinuationOptions)

[image]

.NET Framework Class Library
TaskFactory..::.ContinueWhenAll<(Of <(TResult>)>) Method (array<Task>[]()[], Func<(Of <(array<Task>[]()[], TResult>)>), TaskContinuationOptions)
TaskFactory Class See Also Send Feedback

Creates a continuation Task that will be started upon the completion of a set of provided Tasks.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Function ContinueWhenAll(Of TResult) ( _
    tasks As Task(), _
    continuationFunction As Func(Of Task(), TResult), _
    continuationOptions As TaskContinuationOptions _
) As Task(Of TResult)
C#
public Task<TResult> ContinueWhenAll<TResult>(
    Task[] tasks,
    Func<Task[], TResult> continuationFunction,
    TaskContinuationOptions continuationOptions
)

Parameters

tasks
Type: array< System.Threading.Tasks..::.Task >[]()[]
The array of tasks from which to continue.
continuationFunction
Type: System..::.Func<(Of <(array< Task >[]()[], TResult>)>)
The function delegate to execute when all tasks in the tasks array have completed.
continuationOptions
Type: System.Threading.Tasks..::.TaskContinuationOptions
The TaskContinuationOptions value that controls the behavior of the created continuation Task.

Type Parameters

TResult
The type of the result that is returned by the continuationFunction delegate and associated with the created Task<(Of <(TResult>)>).

Return Value

The new continuation Task<(Of <(TResult>)>).

Remarks

The NotOn* and OnlyOn* TaskContinuationOptions, which constrain for which TaskStatus states a continuation will be executed, are illegal with ContinueWhenAll.

Exceptions

Exception | Condition
System..::.ArgumentNullException | The exception that is thrown when the tasks array is null.
System..::.ArgumentNullException | The exception that is thrown when the continuationFunction argument is null.
System..::.ArgumentException | The exception that is thrown when the tasks array contains a null value.
System..::.ArgumentException | The exception that is thrown when the tasks array is empty.
System..::.ArgumentOutOfRangeException | The exception that is thrown when the continuationOptions argument specifies an invalid TaskContinuationOptions value.
System..::.ObjectDisposedException | The exception that is thrown when one of the elements in the tasks array has been disposed.

See Also

TaskFactory Class
ContinueWhenAll Overload
System.Threading.Tasks Namespace


ContinueWhenAll(TAntecedentResult) Method (Task(TAntecedentResult)[], Action(Task(TAntecedentResult)[]), CancellationToken)

[image]

.NET Framework Class Library
TaskFactory..::.ContinueWhenAll<(Of <(TAntecedentResult>)>) Method (array<Task<(Of <(TAntecedentResult>)>)>[]()[], Action<(Of <(array<Task<(Of <(TAntecedentResult>)>)>[]()[]>)>), CancellationToken)
TaskFactory Class See Also Send Feedback

Creates a continuation Task that will be started upon the completion of a set of provided Tasks.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Function ContinueWhenAll(Of TAntecedentResult) ( _
    tasks As Task(Of TAntecedentResult)(), _
    continuationAction As Action(Of Task(Of TAntecedentResult)()), _
    cancellationToken As CancellationToken _
) As Task
C#
public Task ContinueWhenAll<TAntecedentResult>(
    Task<TAntecedentResult>[] tasks,
    Action<Task<TAntecedentResult>[]> continuationAction,
    CancellationToken cancellationToken
)

Parameters

tasks
Type: array< System.Threading.Tasks..::.Task <(Of <(TAntecedentResult>)>) >[]()[]
The array of tasks from which to continue.
continuationAction
Type: System..::.Action<(Of <(array< Task <(Of <(TAntecedentResult>)>) >[]()[]>)>)
The action delegate to execute when all tasks in the tasks array have completed.
cancellationToken
Type: System.Threading..::.CancellationToken
The CancellationToken that will be assigned to the new continuation task.

Type Parameters

TAntecedentResult
The type of the result of the antecedent tasks.

Return Value

The new continuation Task.

Exceptions

Exception | Condition
System..::.ArgumentNullException | The exception that is thrown when the tasks array is null.
System..::.ArgumentNullException | The exception that is thrown when the continuationAction argument is null.
System..::.ArgumentException | The exception that is thrown when the tasks array contains a null value.
System..::.ArgumentException | The exception that is thrown when the tasks array is empty.
System..::.ObjectDisposedException | The exception that is thrown when one of the elements in the tasks array has been disposed.
System..::.ObjectDisposedException | The provided CancellationToken has already been disposed.

See Also

TaskFactory Class
ContinueWhenAll Overload
System.Threading.Tasks Namespace


ContinueWhenAll(TAntecedentResult) Method (Task(TAntecedentResult)[], Action(Task(TAntecedentResult)[]), TaskContinuationOptions)

[image]

.NET Framework Class Library
TaskFactory..::.ContinueWhenAll<(Of <(TAntecedentResult>)>) Method (array<Task<(Of <(TAntecedentResult>)>)>[]()[], Action<(Of <(array<Task<(Of <(TAntecedentResult>)>)>[]()[]>)>), TaskContinuationOptions)
TaskFactory Class See Also Send Feedback

Creates a continuation Task that will be started upon the completion of a set of provided Tasks.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Function ContinueWhenAll(Of TAntecedentResult) ( _
    tasks As Task(Of TAntecedentResult)(), _
    continuationAction As Action(Of Task(Of TAntecedentResult)()), _
    continuationOptions As TaskContinuationOptions _
) As Task
C#
public Task ContinueWhenAll<TAntecedentResult>(
    Task<TAntecedentResult>[] tasks,
    Action<Task<TAntecedentResult>[]> continuationAction,
    TaskContinuationOptions continuationOptions
)

Parameters

tasks
Type: array< System.Threading.Tasks..::.Task <(Of <(TAntecedentResult>)>) >[]()[]
The array of tasks from which to continue.
continuationAction
Type: System..::.Action<(Of <(array< Task <(Of <(TAntecedentResult>)>) >[]()[]>)>)
The action delegate to execute when all tasks in the tasks array have completed.
continuationOptions
Type: System.Threading.Tasks..::.TaskContinuationOptions
The TaskContinuationOptions value that controls the behavior of the created continuation Task.

Type Parameters

TAntecedentResult
The type of the result of the antecedent tasks.

Return Value

The new continuation Task.

Remarks

The NotOn* and OnlyOn* TaskContinuationOptions, which constrain for which TaskStatus states a continuation will be executed, are illegal with ContinueWhenAll.

Exceptions

Exception | Condition
System..::.ArgumentNullException | The exception that is thrown when the tasks array is null.
System..::.ArgumentNullException | The exception that is thrown when the continuationAction argument is null.
System..::.ArgumentException | The exception that is thrown when the tasks array contains a null value.
System..::.ArgumentException | The exception that is thrown when the tasks array is empty.
System..::.ArgumentOutOfRangeException | The exception that is thrown when the continuationOptions argument specifies an invalid TaskContinuationOptions value.
System..::.ObjectDisposedException | The exception that is thrown when one of the elements in the tasks array has been disposed.

See Also

TaskFactory Class
ContinueWhenAll Overload
System.Threading.Tasks Namespace


ContinueWhenAll(TAntecedentResult, TResult) Method (Task(TAntecedentResult)[], Func(Task(TAntecedentResult)[], TResult), CancellationToken)

[image]

.NET Framework Class Library
TaskFactory..::.ContinueWhenAll<(Of <(TAntecedentResult, TResult>)>) Method (array<Task<(Of <(TAntecedentResult>)>)>[]()[], Func<(Of <(array<Task<(Of <(TAntecedentResult>)>)>[]()[], TResult>)>), CancellationToken)
TaskFactory Class See Also Send Feedback

Creates a continuation Task that will be started upon the completion of a set of provided Tasks.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Function ContinueWhenAll(Of TAntecedentResult, TResult) ( _
    tasks As Task(Of TAntecedentResult)(), _
    continuationFunction As Func(Of Task(Of TAntecedentResult)(), TResult), _
    cancellationToken As CancellationToken _
) As Task(Of TResult)
C#
public Task<TResult> ContinueWhenAll<TAntecedentResult, TResult>(
    Task<TAntecedentResult>[] tasks,
    Func<Task<TAntecedentResult>[], TResult> continuationFunction,
    CancellationToken cancellationToken
)

Parameters

tasks
Type: array< System.Threading.Tasks..::.Task <(Of <(TAntecedentResult>)>) >[]()[]
The array of tasks from which to continue.
continuationFunction
Type: System..::.Func<(Of <(array< Task <(Of <(TAntecedentResult>)>) >[]()[], TResult>)>)
The function delegate to execute when all tasks in the tasks array have completed.
cancellationToken
Type: System.Threading..::.CancellationToken
The CancellationToken that will be assigned to the new continuation task.

Type Parameters

TAntecedentResult
The type of the result of the antecedent tasks.
TResult
The type of the result that is returned by the continuationFunction delegate and associated with the created Task<(Of <(TResult>)>).

Return Value

The new continuation Task<(Of <(TResult>)>).

Exceptions

Exception | Condition
System..::.ArgumentNullException | The exception that is thrown when the tasks array is null.
System..::.ArgumentNullException | The exception that is thrown when the continuationFunction argument is null.
System..::.ArgumentException | The exception that is thrown when the tasks array contains a null value.
System..::.ArgumentException | The exception that is thrown when the tasks array is empty.
System..::.ObjectDisposedException | The exception that is thrown when one of the elements in the tasks array has been disposed.
System..::.ObjectDisposedException | The provided CancellationToken has already been disposed.

See Also

TaskFactory Class
ContinueWhenAll Overload
System.Threading.Tasks Namespace


ContinueWhenAll(TAntecedentResult, TResult) Method (Task(TAntecedentResult)[], Func(Task(TAntecedentResult)[], TResult), TaskContinuationOptions)

[image]

.NET Framework Class Library
TaskFactory..::.ContinueWhenAll<(Of <(TAntecedentResult, TResult>)>) Method (array<Task<(Of <(TAntecedentResult>)>)>[]()[], Func<(Of <(array<Task<(Of <(TAntecedentResult>)>)>[]()[], TResult>)>), TaskContinuationOptions)
TaskFactory Class See Also Send Feedback

Creates a continuation Task that will be started upon the completion of a set of provided Tasks.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Function ContinueWhenAll(Of TAntecedentResult, TResult) ( _
    tasks As Task(Of TAntecedentResult)(), _
    continuationFunction As Func(Of Task(Of TAntecedentResult)(), TResult), _
    continuationOptions As TaskContinuationOptions _
) As Task(Of TResult)
C#
public Task<TResult> ContinueWhenAll<TAntecedentResult, TResult>(
    Task<TAntecedentResult>[] tasks,
    Func<Task<TAntecedentResult>[], TResult> continuationFunction,
    TaskContinuationOptions continuationOptions
)

Parameters

tasks
Type: array< System.Threading.Tasks..::.Task <(Of <(TAntecedentResult>)>) >[]()[]
The array of tasks from which to continue.
continuationFunction
Type: System..::.Func<(Of <(array< Task <(Of <(TAntecedentResult>)>) >[]()[], TResult>)>)
The function delegate to execute when all tasks in the tasks array have completed.
continuationOptions
Type: System.Threading.Tasks..::.TaskContinuationOptions
The TaskContinuationOptions value that controls the behavior of the created continuation Task.

Type Parameters

TAntecedentResult
The type of the result of the antecedent tasks.
TResult
The type of the result that is returned by the continuationFunction delegate and associated with the created Task<(Of <(TResult>)>).

Return Value

The new continuation Task<(Of <(TResult>)>).

Remarks

The NotOn* and OnlyOn* TaskContinuationOptions, which constrain for which TaskStatus states a continuation will be executed, are illegal with ContinueWhenAll.

Exceptions

Exception | Condition
System..::.ArgumentNullException | The exception that is thrown when the tasks array is null.
System..::.ArgumentNullException | The exception that is thrown when the continuationFunction argument is null.
System..::.ArgumentException | The exception that is thrown when the tasks array contains a null value.
System..::.ArgumentException | The exception that is thrown when the tasks array is empty.
System..::.ArgumentOutOfRangeException | The exception that is thrown when the continuationOptions argument specifies an invalid TaskContinuationOptions value.
System..::.ObjectDisposedException | The exception that is thrown when one of the elements in the tasks array has been disposed.

See Also

TaskFactory Class
ContinueWhenAll Overload
System.Threading.Tasks Namespace


ContinueWhenAll Method (Task[], Action(Task[]), CancellationToken, TaskContinuationOptions, TaskScheduler)

[image]

.NET Framework Class Library
TaskFactory..::.ContinueWhenAll Method (array<Task>[]()[], Action<(Of <(array<Task>[]()[]>)>), CancellationToken, TaskContinuationOptions, TaskScheduler)
TaskFactory Class See Also Send Feedback

Creates a continuation Task that will be started upon the completion of a set of provided Tasks.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Function ContinueWhenAll ( _
    tasks As Task(), _
    continuationAction As Action(Of Task()), _
    cancellationToken As CancellationToken, _
    continuationOptions As TaskContinuationOptions, _
    scheduler As TaskScheduler _
) As Task
C#
public Task ContinueWhenAll(
    Task[] tasks,
    Action<Task[]> continuationAction,
    CancellationToken cancellationToken,
    TaskContinuationOptions continuationOptions,
    TaskScheduler scheduler
)

Parameters

tasks
Type: array< System.Threading.Tasks..::.Task >[]()[]
The array of tasks from which to continue.
continuationAction
Type: System..::.Action<(Of <(array< Task >[]()[]>)>)
The action delegate to execute when all tasks in the tasks array have completed.
cancellationToken
Type: System.Threading..::.CancellationToken
The CancellationToken that will be assigned to the new continuation task.
continuationOptions
Type: System.Threading.Tasks..::.TaskContinuationOptions
The TaskContinuationOptions value that controls the behavior of the created continuation Task.
scheduler
Type: System.Threading.Tasks..::.TaskScheduler
The TaskScheduler that is used to schedule the created continuation Task.

Return Value

The new continuation Task.

Remarks

The NotOn* and OnlyOn* TaskContinuationOptions, which constrain for which TaskStatus states a continuation will be executed, are illegal with ContinueWhenAll.

Exceptions

Exception | Condition
System..::.ArgumentNullException | The exception that is thrown when the tasks array is null.
System..::.ArgumentNullException | The exception that is thrown when the continuationAction argument is null.
System..::.ArgumentNullException | The exception that is thrown when the scheduler argument is null.
System..::.ArgumentException | The exception that is thrown when the tasks array contains a null value.
System..::.ArgumentException | The exception that is thrown when the tasks array is empty.
System..::.ArgumentOutOfRangeException | The exception that is thrown when the continuationOptions argument specifies an invalid TaskContinuationOptions value.
System..::.ObjectDisposedException | The exception that is thrown when one of the elements in the tasks array has been disposed.
System..::.ObjectDisposedException | The provided CancellationToken has already been disposed.

See Also

TaskFactory Class
ContinueWhenAll Overload
System.Threading.Tasks Namespace


ContinueWhenAll(TResult) Method (Task[], Func(Task[], TResult), CancellationToken, TaskContinuationOptions, TaskScheduler)

[image]

.NET Framework Class Library
TaskFactory..::.ContinueWhenAll<(Of <(TResult>)>) Method (array<Task>[]()[], Func<(Of <(array<Task>[]()[], TResult>)>), CancellationToken, TaskContinuationOptions, TaskScheduler)
TaskFactory Class See Also Send Feedback

Creates a continuation Task that will be started upon the completion of a set of provided Tasks.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Function ContinueWhenAll(Of TResult) ( _
    tasks As Task(), _
    continuationFunction As Func(Of Task(), TResult), _
    cancellationToken As CancellationToken, _
    continuationOptions As TaskContinuationOptions, _
    scheduler As TaskScheduler _
) As Task(Of TResult)
C#
public Task<TResult> ContinueWhenAll<TResult>(
    Task[] tasks,
    Func<Task[], TResult> continuationFunction,
    CancellationToken cancellationToken,
    TaskContinuationOptions continuationOptions,
    TaskScheduler scheduler
)

Parameters

tasks
Type: array< System.Threading.Tasks..::.Task >[]()[]
The array of tasks from which to continue.
continuationFunction
Type: System..::.Func<(Of <(array< Task >[]()[], TResult>)>)
The function delegate to execute when all tasks in the tasks array have completed.
cancellationToken
Type: System.Threading..::.CancellationToken
The CancellationToken that will be assigned to the new continuation task.
continuationOptions
Type: System.Threading.Tasks..::.TaskContinuationOptions
The TaskContinuationOptions value that controls the behavior of the created continuation Task.
scheduler
Type: System.Threading.Tasks..::.TaskScheduler
The TaskScheduler that is used to schedule the created continuation Task<(Of <(TResult>)>).

Type Parameters

TResult
The type of the result that is returned by the continuationFunction delegate and associated with the created Task<(Of <(TResult>)>).

Return Value

The new continuation Task<(Of <(TResult>)>).

Remarks

The NotOn* and OnlyOn* TaskContinuationOptions, which constrain for which TaskStatus states a continuation will be executed, are illegal with ContinueWhenAll.

Exceptions

Exception | Condition
System..::.ArgumentNullException | The exception that is thrown when the tasks array is null.
System..::.ArgumentNullException | The exception that is thrown when the continuationFunction argument is null.
System..::.ArgumentNullException | The exception that is thrown when the scheduler argument is null.
System..::.ArgumentException | The exception that is thrown when the tasks array contains a null value.
System..::.ArgumentException | The exception that is thrown when the tasks array is empty.
System..::.ArgumentOutOfRangeException | The exception that is thrown when the continuationOptions argument specifies an invalid TaskContinuationOptions value.
System..::.ObjectDisposedException | The exception that is thrown when one of the elements in the tasks array has been disposed.
System..::.ObjectDisposedException | The provided CancellationToken has already been disposed.

See Also

TaskFactory Class
ContinueWhenAll Overload
System.Threading.Tasks Namespace


ContinueWhenAll(TAntecedentResult) Method (Task(TAntecedentResult)[], Action(Task(TAntecedentResult)[]), CancellationToken, TaskContinuationOptions, TaskScheduler)

[image]

.NET Framework Class Library
TaskFactory..::.ContinueWhenAll<(Of <(TAntecedentResult>)>) Method (array<Task<(Of <(TAntecedentResult>)>)>[]()[], Action<(Of <(array<Task<(Of <(TAntecedentResult>)>)>[]()[]>)>), CancellationToken, TaskContinuationOptions, TaskScheduler)
TaskFactory Class See Also Send Feedback

Creates a continuation Task that will be started upon the completion of a set of provided Tasks.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Function ContinueWhenAll(Of TAntecedentResult) ( _
    tasks As Task(Of TAntecedentResult)(), _
    continuationAction As Action(Of Task(Of TAntecedentResult)()), _
    cancellationToken As CancellationToken, _
    continuationOptions As TaskContinuationOptions, _
    scheduler As TaskScheduler _
) As Task
C#
public Task ContinueWhenAll<TAntecedentResult>(
    Task<TAntecedentResult>[] tasks,
    Action<Task<TAntecedentResult>[]> continuationAction,
    CancellationToken cancellationToken,
    TaskContinuationOptions continuationOptions,
    TaskScheduler scheduler
)

Parameters

tasks
Type: array< System.Threading.Tasks..::.Task <(Of <(TAntecedentResult>)>) >[]()[]
The array of tasks from which to continue.
continuationAction
Type: System..::.Action<(Of <(array< Task <(Of <(TAntecedentResult>)>) >[]()[]>)>)
The action delegate to execute when all tasks in the tasks array have completed.
cancellationToken
Type: System.Threading..::.CancellationToken
The CancellationToken that will be assigned to the new continuation task.
continuationOptions
Type: System.Threading.Tasks..::.TaskContinuationOptions
The TaskContinuationOptions value that controls the behavior of the created continuation Task.
scheduler
Type: System.Threading.Tasks..::.TaskScheduler
The TaskScheduler that is used to schedule the created continuation Task.

Type Parameters

TAntecedentResult
The type of the result of the antecedent tasks.

Return Value

The new continuation Task.

Remarks

The NotOn* and OnlyOn* TaskContinuationOptions, which constrain for which TaskStatus states a continuation will be executed, are illegal with ContinueWhenAll.

Exceptions

Exception | Condition
System..::.ArgumentNullException | The exception that is thrown when the tasks array is null.
System..::.ArgumentNullException | The exception that is thrown when the continuationAction argument is null.
System..::.ArgumentNullException | The exception that is thrown when the scheduler argument is null.
System..::.ArgumentException | The exception that is thrown when the tasks array contains a null value.
System..::.ArgumentException | The exception that is thrown when the tasks array is empty.
System..::.ArgumentOutOfRangeException | The exception that is thrown when the continuationOptions argument specifies an invalid TaskContinuationOptions value.
System..::.ObjectDisposedException | The exception that is thrown when one of the elements in the tasks array has been disposed.
System..::.ObjectDisposedException | The provided CancellationToken has already been disposed.

See Also

TaskFactory Class
ContinueWhenAll Overload
System.Threading.Tasks Namespace


ContinueWhenAll(TAntecedentResult, TResult) Method (Task(TAntecedentResult)[], Func(Task(TAntecedentResult)[], TResult), CancellationToken, TaskContinuationOptions, TaskScheduler)

[image]

.NET Framework Class Library
TaskFactory..::.ContinueWhenAll<(Of <(TAntecedentResult, TResult>)>) Method (array<Task<(Of <(TAntecedentResult>)>)>[]()[], Func<(Of <(array<Task<(Of <(TAntecedentResult>)>)>[]()[], TResult>)>), CancellationToken, TaskContinuationOptions, TaskScheduler)
TaskFactory Class See Also Send Feedback

Creates a continuation Task that will be started upon the completion of a set of provided Tasks.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Function ContinueWhenAll(Of TAntecedentResult, TResult) ( _
    tasks As Task(Of TAntecedentResult)(), _
    continuationFunction As Func(Of Task(Of TAntecedentResult)(), TResult), _
    cancellationToken As CancellationToken, _
    continuationOptions As TaskContinuationOptions, _
    scheduler As TaskScheduler _
) As Task(Of TResult)
C#
public Task<TResult> ContinueWhenAll<TAntecedentResult, TResult>(
    Task<TAntecedentResult>[] tasks,
    Func<Task<TAntecedentResult>[], TResult> continuationFunction,
    CancellationToken cancellationToken,
    TaskContinuationOptions continuationOptions,
    TaskScheduler scheduler
)

Parameters

tasks
Type: array< System.Threading.Tasks..::.Task <(Of <(TAntecedentResult>)>) >[]()[]
The array of tasks from which to continue.
continuationFunction
Type: System..::.Func<(Of <(array< Task <(Of <(TAntecedentResult>)>) >[]()[], TResult>)>)
The function delegate to execute when all tasks in the tasks array have completed.
cancellationToken
Type: System.Threading..::.CancellationToken
The CancellationToken that will be assigned to the new continuation task.
continuationOptions
Type: System.Threading.Tasks..::.TaskContinuationOptions
The TaskContinuationOptions value that controls the behavior of the created continuation Task.
scheduler
Type: System.Threading.Tasks..::.TaskScheduler
The TaskScheduler that is used to schedule the created continuation Task<(Of <(TResult>)>).

Type Parameters

TAntecedentResult
The type of the result of the antecedent tasks.
TResult
The type of the result that is returned by the continuationFunction delegate and associated with the created Task<(Of <(TResult>)>).

Return Value

The new continuation Task<(Of <(TResult>)>).

Remarks

The NotOn* and OnlyOn* TaskContinuationOptions, which constrain for which TaskStatus states a continuation will be executed, are illegal with ContinueWhenAll.

Exceptions

Exception | Condition
System..::.ArgumentNullException | The exception that is thrown when the tasks array is null.
System..::.ArgumentNullException | The exception that is thrown when the continuationFunction argument is null.
System..::.ArgumentNullException | The exception that is thrown when the scheduler argument is null.
System..::.ArgumentException | The exception that is thrown when the tasks array contains a null value.
System..::.ArgumentException | The exception that is thrown when the tasks array is empty.
System..::.ArgumentOutOfRangeException | The exception that is thrown when the continuationOptions argument specifies an invalid TaskContinuationOptions value.
System..::.ObjectDisposedException | The exception that is thrown when one of the elements in the tasks array has been disposed.
System..::.ObjectDisposedException | The provided CancellationToken has already been disposed.

See Also

TaskFactory Class
ContinueWhenAll Overload
System.Threading.Tasks Namespace


ContinueWhenAny Method

[image] [image]

.NET Framework Class Library
TaskFactory..::.ContinueWhenAny Method
TaskFactory Class See Also Send Feedback

Overload List

Name | Description
ContinueWhenAny(array<Task>[]()[], Action<(Of <(Task>)>)) | Creates a continuation Task that will be started upon the completion of any Task in the provided set.
ContinueWhenAny<(Of <(TResult>)>)(array<Task>[]()[], Func<(Of <(Task, TResult>)>)) | Creates a continuation Task that will be started upon the completion of any Task in the provided set.
ContinueWhenAny<(Of <(TAntecedentResult>)>)(array<Task<(Of <(TAntecedentResult>)>)>[]()[], Action<(Of <(Task<(Of <(TAntecedentResult>)>)>)>)) | Creates a continuation Task that will be started upon the completion of any Task in the provided set.
ContinueWhenAny<(Of <(TAntecedentResult, TResult>)>)(array<Task<(Of <(TAntecedentResult>)>)>[]()[], Func<(Of <(Task<(Of <(TAntecedentResult>)>), TResult>)>)) | Creates a continuation Task that will be started upon the completion of any Task in the provided set.
ContinueWhenAny(array<Task>[]()[], Action<(Of <(Task>)>), CancellationToken) | Creates a continuation Task that will be started upon the completion of any Task in the provided set.
ContinueWhenAny(array<Task>[]()[], Action<(Of <(Task>)>), TaskContinuationOptions) | Creates a continuation Task that will be started upon the completion of any Task in the provided set.
ContinueWhenAny<(Of <(TResult>)>)(array<Task>[]()[], Func<(Of <(Task, TResult>)>), CancellationToken) | Creates a continuation Task that will be started upon the completion of any Task in the provided set.
ContinueWhenAny<(Of <(TResult>)>)(array<Task>[]()[], Func<(Of <(Task, TResult>)>), TaskContinuationOptions) | Creates a continuation Task that will be started upon the completion of any Task in the provided set.
ContinueWhenAny<(Of <(TAntecedentResult>)>)(array<Task<(Of <(TAntecedentResult>)>)>[]()[], Action<(Of <(Task<(Of <(TAntecedentResult>)>)>)>), CancellationToken) | Creates a continuation Task that will be started upon the completion of any Task in the provided set.
ContinueWhenAny<(Of <(TAntecedentResult>)>)(array<Task<(Of <(TAntecedentResult>)>)>[]()[], Action<(Of <(Task<(Of <(TAntecedentResult>)>)>)>), TaskContinuationOptions) | Creates a continuation Task that will be started upon the completion of any Task in the provided set.
ContinueWhenAny<(Of <(TAntecedentResult, TResult>)>)(array<Task<(Of <(TAntecedentResult>)>)>[]()[], Func<(Of <(Task<(Of <(TAntecedentResult>)>), TResult>)>), CancellationToken) | Creates a continuation Task that will be started upon the completion of any Task in the provided set.
ContinueWhenAny<(Of <(TAntecedentResult, TResult>)>)(array<Task<(Of <(TAntecedentResult>)>)>[]()[], Func<(Of <(Task<(Of <(TAntecedentResult>)>), TResult>)>), TaskContinuationOptions) | Creates a continuation Task that will be started upon the completion of any Task in the provided set.
ContinueWhenAny(array<Task>[]()[], Action<(Of <(Task>)>), CancellationToken, TaskContinuationOptions, TaskScheduler) | Creates a continuation Task that will be started upon the completion of any Task in the provided set.
ContinueWhenAny<(Of <(TResult>)>)(array<Task>[]()[], Func<(Of <(Task, TResult>)>), CancellationToken, TaskContinuationOptions, TaskScheduler) | Creates a continuation Task that will be started upon the completion of any Task in the provided set.
ContinueWhenAny<(Of <(TAntecedentResult>)>)(array<Task<(Of <(TAntecedentResult>)>)>[]()[], Action<(Of <(Task<(Of <(TAntecedentResult>)>)>)>), CancellationToken, TaskContinuationOptions, TaskScheduler) | Creates a continuation Task that will be started upon the completion of any Task in the provided set.
ContinueWhenAny<(Of <(TAntecedentResult, TResult>)>)(array<Task<(Of <(TAntecedentResult>)>)>[]()[], Func<(Of <(Task<(Of <(TAntecedentResult>)>), TResult>)>), CancellationToken, TaskContinuationOptions, TaskScheduler) | Creates a continuation Task that will be started upon the completion of any Task in the provided set.

See Also

TaskFactory Class
System.Threading.Tasks Namespace


ContinueWhenAny Method (Task[], Action(Task))

[image]

.NET Framework Class Library
TaskFactory..::.ContinueWhenAny Method (array<Task>[]()[], Action<(Of <(Task>)>))
TaskFactory Class See Also Send Feedback

Creates a continuation Task that will be started upon the completion of any Task in the provided set.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Function ContinueWhenAny ( _
    tasks As Task(), _
    continuationAction As Action(Of Task) _
) As Task
C#
public Task ContinueWhenAny(
    Task[] tasks,
    Action<Task> continuationAction
)

Parameters

tasks
Type: array< System.Threading.Tasks..::.Task >[]()[]
The array of tasks from which to continue when one task completes.
continuationAction
Type: System..::.Action<(Of <( Task >)>)
The action delegate to execute when one task in the tasks array completes.

Return Value

The new continuation Task.

Exceptions

Exception | Condition
System..::.ArgumentNullException | The exception that is thrown when the tasks array is null.
System..::.ArgumentNullException | The exception that is thrown when the continuationAction argument is null.
System..::.ArgumentException | The exception that is thrown when the tasks array contains a null value.
System..::.ArgumentException | The exception that is thrown when the tasks array is empty.
System..::.ObjectDisposedException | The exception that is thrown when one of the elements in the tasks array has been disposed.

See Also

TaskFactory Class
ContinueWhenAny Overload
System.Threading.Tasks Namespace


ContinueWhenAny(TResult) Method (Task[], Func(Task, TResult))

[image]

.NET Framework Class Library
TaskFactory..::.ContinueWhenAny<(Of <(TResult>)>) Method (array<Task>[]()[], Func<(Of <(Task, TResult>)>))
TaskFactory Class See Also Send Feedback

Creates a continuation Task that will be started upon the completion of any Task in the provided set.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Function ContinueWhenAny(Of TResult) ( _
    tasks As Task(), _
    continuationFunction As Func(Of Task, TResult) _
) As Task(Of TResult)
C#
public Task<TResult> ContinueWhenAny<TResult>(
    Task[] tasks,
    Func<Task, TResult> continuationFunction
)

Parameters

tasks
Type: array< System.Threading.Tasks..::.Task >[]()[]
The array of tasks from which to continue when one task completes.
continuationFunction
Type: System..::.Func<(Of <( Task, TResult>)>)
The function delegate to execute when one task in the tasks array completes.

Type Parameters

TResult
The type of the result that is returned by the continuationFunction delegate and associated with the created Task<(Of <(TResult>)>).

Return Value

The new continuation Task<(Of <(TResult>)>).

Exceptions

Exception | Condition
System..::.ArgumentNullException | The exception that is thrown when the tasks array is null.
System..::.ArgumentNullException | The exception that is thrown when the continuationFunction argument is null.
System..::.ArgumentException | The exception that is thrown when the tasks array contains a null value.
System..::.ArgumentException | The exception that is thrown when the tasks array is empty.
System..::.ObjectDisposedException | The exception that is thrown when one of the elements in the tasks array has been disposed.

See Also

TaskFactory Class
ContinueWhenAny Overload
System.Threading.Tasks Namespace


ContinueWhenAny(TAntecedentResult) Method (Task(TAntecedentResult)[], Action(Task(TAntecedentResult)))

[image]

.NET Framework Class Library
TaskFactory..::.ContinueWhenAny<(Of <(TAntecedentResult>)>) Method (array<Task<(Of <(TAntecedentResult>)>)>[]()[], Action<(Of <(Task<(Of <(TAntecedentResult>)>)>)>))
TaskFactory Class See Also Send Feedback

Creates a continuation Task that will be started upon the completion of any Task in the provided set.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Function ContinueWhenAny(Of TAntecedentResult) ( _
    tasks As Task(Of TAntecedentResult)(), _
    continuationAction As Action(Of Task(Of TAntecedentResult)) _
) As Task
C#
public Task ContinueWhenAny<TAntecedentResult>(
    Task<TAntecedentResult>[] tasks,
    Action<Task<TAntecedentResult>> continuationAction
)

Parameters

tasks
Type: array< System.Threading.Tasks..::.Task <(Of <(TAntecedentResult>)>) >[]()[]
The array of tasks from which to continue when one task completes.
continuationAction
Type: System..::.Action<(Of <( Task <(Of <(TAntecedentResult>)>)>)>)
The action delegate to execute when one task in the tasks array completes.

Type Parameters

TAntecedentResult
The type of the result of the antecedent tasks.

Return Value

The new continuation Task.

Exceptions

Exception | Condition
System..::.ArgumentNullException | The exception that is thrown when the tasks array is null.
System..::.ArgumentNullException | The exception that is thrown when the continuationAction argument is null.
System..::.ArgumentException | The exception that is thrown when the tasks array contains a null value.
System..::.ArgumentException | The exception that is thrown when the tasks array is empty.
System..::.ObjectDisposedException | The exception that is thrown when one of the elements in the tasks array has been disposed.

See Also

TaskFactory Class
ContinueWhenAny Overload
System.Threading.Tasks Namespace


ContinueWhenAny(TAntecedentResult, TResult) Method (Task(TAntecedentResult)[], Func(Task(TAntecedentResult), TResult))

[image]

.NET Framework Class Library
TaskFactory..::.ContinueWhenAny<(Of <(TAntecedentResult, TResult>)>) Method (array<Task<(Of <(TAntecedentResult>)>)>[]()[], Func<(Of <(Task<(Of <(TAntecedentResult>)>), TResult>)>))
TaskFactory Class See Also Send Feedback

Creates a continuation Task that will be started upon the completion of any Task in the provided set.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Function ContinueWhenAny(Of TAntecedentResult, TResult) ( _
    tasks As Task(Of TAntecedentResult)(), _
    continuationFunction As Func(Of Task(Of TAntecedentResult), TResult) _
) As Task(Of TResult)
C#
public Task<TResult> ContinueWhenAny<TAntecedentResult, TResult>(
    Task<TAntecedentResult>[] tasks,
    Func<Task<TAntecedentResult>, TResult> continuationFunction
)

Parameters

tasks
Type: array< System.Threading.Tasks..::.Task <(Of <(TAntecedentResult>)>) >[]()[]
The array of tasks from which to continue when one task completes.
continuationFunction
Type: System..::.Func<(Of <( Task <(Of <(TAntecedentResult>)>), TResult>)>)
The function delegate to execute when one task in the tasks array completes.

Type Parameters

TAntecedentResult
The type of the result of the antecedent tasks.
TResult
The type of the result that is returned by the continuationFunction delegate and associated with the created Task<(Of <(TResult>)>).

Return Value

The new continuation Task<(Of <(TResult>)>).

Exceptions

Exception | Condition
System..::.ArgumentNullException | The exception that is thrown when the tasks array is null.
System..::.ArgumentNullException | The exception that is thrown when the continuationFunction argument is null.
System..::.ArgumentException | The exception that is thrown when the tasks array contains a null value.
System..::.ArgumentException | The exception that is thrown when the tasks array is empty.
System..::.ObjectDisposedException | The exception that is thrown when one of the elements in the tasks array has been disposed.

See Also

TaskFactory Class
ContinueWhenAny Overload
System.Threading.Tasks Namespace


ContinueWhenAny Method (Task[], Action(Task), CancellationToken)

[image]

.NET Framework Class Library
TaskFactory..::.ContinueWhenAny Method (array<Task>[]()[], Action<(Of <(Task>)>), CancellationToken)
TaskFactory Class See Also Send Feedback

Creates a continuation Task that will be started upon the completion of any Task in the provided set.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Function ContinueWhenAny ( _
    tasks As Task(), _
    continuationAction As Action(Of Task), _
    cancellationToken As CancellationToken _
) As Task
C#
public Task ContinueWhenAny(
    Task[] tasks,
    Action<Task> continuationAction,
    CancellationToken cancellationToken
)

Parameters

tasks
Type: array< System.Threading.Tasks..::.Task >[]()[]
The array of tasks from which to continue when one task completes.
continuationAction
Type: System..::.Action<(Of <( Task >)>)
The action delegate to execute when one task in the tasks array completes.
cancellationToken
Type: System.Threading..::.CancellationToken
The CancellationToken that will be assigned to the new continuation task.

Return Value

The new continuation Task.

Exceptions

Exception | Condition
System..::.ArgumentNullException | The exception that is thrown when the tasks array is null.
System..::.ArgumentNullException | The exception that is thrown when the continuationAction argument is null.
System..::.ArgumentException | The exception that is thrown when the tasks array contains a null value.
System..::.ArgumentException | The exception that is thrown when the tasks array is empty.
System..::.ObjectDisposedException | The exception that is thrown when one of the elements in the tasks array has been disposed.
System..::.ObjectDisposedException | The provided CancellationToken has already been disposed.

See Also

TaskFactory Class
ContinueWhenAny Overload
System.Threading.Tasks Namespace


ContinueWhenAny Method (Task[], Action(Task), TaskContinuationOptions)

[image]

.NET Framework Class Library
TaskFactory..::.ContinueWhenAny Method (array<Task>[]()[], Action<(Of <(Task>)>), TaskContinuationOptions)
TaskFactory Class See Also Send Feedback

Creates a continuation Task that will be started upon the completion of any Task in the provided set.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Function ContinueWhenAny ( _
    tasks As Task(), _
    continuationAction As Action(Of Task), _
    continuationOptions As TaskContinuationOptions _
) As Task
C#
public Task ContinueWhenAny(
    Task[] tasks,
    Action<Task> continuationAction,
    TaskContinuationOptions continuationOptions
)

Parameters

tasks
Type: array< System.Threading.Tasks..::.Task >[]()[]
The array of tasks from which to continue when one task completes.
continuationAction
Type: System..::.Action<(Of <( Task >)>)
The action delegate to execute when one task in the tasks array completes.
continuationOptions
Type: System.Threading.Tasks..::.TaskContinuationOptions
The TaskContinuationOptions value that controls the behavior of the created continuation Task.

Return Value

The new continuation Task.

Remarks

The NotOn* and OnlyOn* TaskContinuationOptions, which constrain for which TaskStatus states a continuation will be executed, are illegal with ContinueWhenAny.

Exceptions

Exception | Condition
System..::.ArgumentNullException | The exception that is thrown when the tasks array is null.
System..::.ArgumentNullException | The exception that is thrown when the continuationAction argument is null.
System..::.ArgumentException | The exception that is thrown when the tasks array contains a null value.
System..::.ArgumentException | The exception that is thrown when the tasks array is empty.
System..::.ArgumentOutOfRangeException | The exception that is thrown when the continuationOptions argument specifies an invalid TaskContinuationOptions value.
System..::.ObjectDisposedException | The exception that is thrown when one of the elements in the tasks array has been disposed.

See Also

TaskFactory Class
ContinueWhenAny Overload
System.Threading.Tasks Namespace


ContinueWhenAny(TResult) Method (Task[], Func(Task, TResult), CancellationToken)

[image]

.NET Framework Class Library
TaskFactory..::.ContinueWhenAny<(Of <(TResult>)>) Method (array<Task>[]()[], Func<(Of <(Task, TResult>)>), CancellationToken)
TaskFactory Class See Also Send Feedback

Creates a continuation Task that will be started upon the completion of any Task in the provided set.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Function ContinueWhenAny(Of TResult) ( _
    tasks As Task(), _
    continuationFunction As Func(Of Task, TResult), _
    cancellationToken As CancellationToken _
) As Task(Of TResult)
C#
public Task<TResult> ContinueWhenAny<TResult>(
    Task[] tasks,
    Func<Task, TResult> continuationFunction,
    CancellationToken cancellationToken
)

Parameters

tasks
Type: array< System.Threading.Tasks..::.Task >[]()[]
The array of tasks from which to continue when one task completes.
continuationFunction
Type: System..::.Func<(Of <( Task, TResult>)>)
The function delegate to execute when one task in the tasks array completes.
cancellationToken
Type: System.Threading..::.CancellationToken
The CancellationToken that will be assigned to the new continuation task.

Type Parameters

TResult
The type of the result that is returned by the continuationFunction delegate and associated with the created Task<(Of <(TResult>)>).

Return Value

The new continuation Task<(Of <(TResult>)>).

Exceptions

Exception | Condition
System..::.ArgumentNullException | The exception that is thrown when the tasks array is null.
System..::.ArgumentNullException | The exception that is thrown when the continuationFunction argument is null.
System..::.ArgumentException | The exception that is thrown when the tasks array contains a null value.
System..::.ArgumentException | The exception that is thrown when the tasks array is empty.
System..::.ObjectDisposedException | The exception that is thrown when one of the elements in the tasks array has been disposed.
System..::.ObjectDisposedException | The provided CancellationToken has already been disposed.

See Also

TaskFactory Class
ContinueWhenAny Overload
System.Threading.Tasks Namespace


ContinueWhenAny(TResult) Method (Task[], Func(Task, TResult), TaskContinuationOptions)

[image]

.NET Framework Class Library
TaskFactory..::.ContinueWhenAny<(Of <(TResult>)>) Method (array<Task>[]()[], Func<(Of <(Task, TResult>)>), TaskContinuationOptions)
TaskFactory Class See Also Send Feedback

Creates a continuation Task that will be started upon the completion of any Task in the provided set.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Function ContinueWhenAny(Of TResult) ( _
    tasks As Task(), _
    continuationFunction As Func(Of Task, TResult), _
    continuationOptions As TaskContinuationOptions _
) As Task(Of TResult)
C#
public Task<TResult> ContinueWhenAny<TResult>(
    Task[] tasks,
    Func<Task, TResult> continuationFunction,
    TaskContinuationOptions continuationOptions
)

Parameters

tasks
Type: array< System.Threading.Tasks..::.Task >[]()[]
The array of tasks from which to continue when one task completes.
continuationFunction
Type: System..::.Func<(Of <( Task, TResult>)>)
The function delegate to execute when one task in the tasks array completes.
continuationOptions
Type: System.Threading.Tasks..::.TaskContinuationOptions
The TaskContinuationOptions value that controls the behavior of the created continuation Task.

Type Parameters

TResult
The type of the result that is returned by the continuationFunction delegate and associated with the created Task<(Of <(TResult>)>).

Return Value

The new continuation Task<(Of <(TResult>)>).

Remarks

The NotOn* and OnlyOn* TaskContinuationOptions, which constrain for which TaskStatus states a continuation will be executed, are illegal with ContinueWhenAny.

Exceptions

Exception | Condition
System..::.ArgumentNullException | The exception that is thrown when the tasks array is null.
System..::.ArgumentNullException | The exception that is thrown when the continuationFunction argument is null.
System..::.ArgumentException | The exception that is thrown when the tasks array contains a null value.
System..::.ArgumentException | The exception that is thrown when the tasks array is empty.
System..::.ArgumentOutOfRangeException | The exception that is thrown when the continuationOptions argument specifies an invalid TaskContinuationOptions value.
System..::.ObjectDisposedException | The exception that is thrown when one of the elements in the tasks array has been disposed.

See Also

TaskFactory Class
ContinueWhenAny Overload
System.Threading.Tasks Namespace


ContinueWhenAny(TAntecedentResult) Method (Task(TAntecedentResult)[], Action(Task(TAntecedentResult)), CancellationToken)

[image]

.NET Framework Class Library
TaskFactory..::.ContinueWhenAny<(Of <(TAntecedentResult>)>) Method (array<Task<(Of <(TAntecedentResult>)>)>[]()[], Action<(Of <(Task<(Of <(TAntecedentResult>)>)>)>), CancellationToken)
TaskFactory Class See Also Send Feedback

Creates a continuation Task that will be started upon the completion of any Task in the provided set.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Function ContinueWhenAny(Of TAntecedentResult) ( _
    tasks As Task(Of TAntecedentResult)(), _
    continuationAction As Action(Of Task(Of TAntecedentResult)), _
    cancellationToken As CancellationToken _
) As Task
C#
public Task ContinueWhenAny<TAntecedentResult>(
    Task<TAntecedentResult>[] tasks,
    Action<Task<TAntecedentResult>> continuationAction,
    CancellationToken cancellationToken
)

Parameters

tasks
Type: array< System.Threading.Tasks..::.Task <(Of <(TAntecedentResult>)>) >[]()[]
The array of tasks from which to continue when one task completes.
continuationAction
Type: System..::.Action<(Of <( Task <(Of <(TAntecedentResult>)>)>)>)
The action delegate to execute when one task in the tasks array completes.
cancellationToken
Type: System.Threading..::.CancellationToken
The CancellationToken that will be assigned to the new continuation task.

Type Parameters

TAntecedentResult
The type of the result of the antecedent tasks.

Return Value

The new continuation Task.

Exceptions

Exception | Condition
System..::.ArgumentNullException | The exception that is thrown when the tasks array is null.
System..::.ArgumentNullException | The exception that is thrown when the continuationAction argument is null.
System..::.ArgumentException | The exception that is thrown when the tasks array contains a null value.
System..::.ArgumentException | The exception that is thrown when the tasks array is empty.
System..::.ObjectDisposedException | The exception that is thrown when one of the elements in the tasks array has been disposed.
System..::.ObjectDisposedException | The provided CancellationToken has already been disposed.

See Also

TaskFactory Class
ContinueWhenAny Overload
System.Threading.Tasks Namespace


ContinueWhenAny(TAntecedentResult) Method (Task(TAntecedentResult)[], Action(Task(TAntecedentResult)), TaskContinuationOptions)

[image]

.NET Framework Class Library
TaskFactory..::.ContinueWhenAny<(Of <(TAntecedentResult>)>) Method (array<Task<(Of <(TAntecedentResult>)>)>[]()[], Action<(Of <(Task<(Of <(TAntecedentResult>)>)>)>), TaskContinuationOptions)
TaskFactory Class See Also Send Feedback

Creates a continuation Task that will be started upon the completion of any Task in the provided set.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Function ContinueWhenAny(Of TAntecedentResult) ( _
    tasks As Task(Of TAntecedentResult)(), _
    continuationAction As Action(Of Task(Of TAntecedentResult)), _
    continuationOptions As TaskContinuationOptions _
) As Task
C#
public Task ContinueWhenAny<TAntecedentResult>(
    Task<TAntecedentResult>[] tasks,
    Action<Task<TAntecedentResult>> continuationAction,
    TaskContinuationOptions continuationOptions
)

Parameters

tasks
Type: array< System.Threading.Tasks..::.Task <(Of <(TAntecedentResult>)>) >[]()[]
The array of tasks from which to continue when one task completes.
continuationAction
Type: System..::.Action<(Of <( Task <(Of <(TAntecedentResult>)>)>)>)
The action delegate to execute when one task in the tasks array completes.
continuationOptions
Type: System.Threading.Tasks..::.TaskContinuationOptions
The TaskContinuationOptions value that controls the behavior of the created continuation Task.

Type Parameters

TAntecedentResult
The type of the result of the antecedent tasks.

Return Value

The new continuation Task.

Remarks

The NotOn* and OnlyOn* TaskContinuationOptions, which constrain for which TaskStatus states a continuation will be executed, are illegal with ContinueWhenAny.

Exceptions

Exception | Condition
System..::.ArgumentNullException | The exception that is thrown when the tasks array is null.
System..::.ArgumentNullException | The exception that is thrown when the continuationAction argument is null.
System..::.ArgumentException | The exception that is thrown when the tasks array contains a null value.
System..::.ArgumentException | The exception that is thrown when the tasks array is empty.
System..::.ArgumentOutOfRangeException | The exception that is thrown when the continuationOptions argument specifies an invalid TaskContinuationOptions value.
System..::.ObjectDisposedException | The exception that is thrown when one of the elements in the tasks array has been disposed.

See Also

TaskFactory Class
ContinueWhenAny Overload
System.Threading.Tasks Namespace


ContinueWhenAny(TAntecedentResult, TResult) Method (Task(TAntecedentResult)[], Func(Task(TAntecedentResult), TResult), CancellationToken)

[image]

.NET Framework Class Library
TaskFactory..::.ContinueWhenAny<(Of <(TAntecedentResult, TResult>)>) Method (array<Task<(Of <(TAntecedentResult>)>)>[]()[], Func<(Of <(Task<(Of <(TAntecedentResult>)>), TResult>)>), CancellationToken)
TaskFactory Class See Also Send Feedback

Creates a continuation Task that will be started upon the completion of any Task in the provided set.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Function ContinueWhenAny(Of TAntecedentResult, TResult) ( _
    tasks As Task(Of TAntecedentResult)(), _
    continuationFunction As Func(Of Task(Of TAntecedentResult), TResult), _
    cancellationToken As CancellationToken _
) As Task(Of TResult)
C#
public Task<TResult> ContinueWhenAny<TAntecedentResult, TResult>(
    Task<TAntecedentResult>[] tasks,
    Func<Task<TAntecedentResult>, TResult> continuationFunction,
    CancellationToken cancellationToken
)

Parameters

tasks
Type: array< System.Threading.Tasks..::.Task <(Of <(TAntecedentResult>)>) >[]()[]
The array of tasks from which to continue when one task completes.
continuationFunction
Type: System..::.Func<(Of <( Task <(Of <(TAntecedentResult>)>), TResult>)>)
The function delegate to execute when one task in the tasks array completes.
cancellationToken
Type: System.Threading..::.CancellationToken
The CancellationToken that will be assigned to the new continuation task.

Type Parameters

TAntecedentResult
The type of the result of the antecedent tasks.
TResult
The type of the result that is returned by the continuationFunction delegate and associated with the created Task<(Of <(TResult>)>).

Return Value

The new continuation Task<(Of <(TResult>)>).

Exceptions

Exception | Condition
System..::.ArgumentNullException | The exception that is thrown when the tasks array is null.
System..::.ArgumentNullException | The exception that is thrown when the continuationFunction argument is null.
System..::.ArgumentException | The exception that is thrown when the tasks array contains a null value.
System..::.ArgumentException | The exception that is thrown when the tasks array is empty.
System..::.ObjectDisposedException | The exception that is thrown when one of the elements in the tasks array has been disposed.
System..::.ObjectDisposedException | The provided CancellationToken has already been disposed.

See Also

TaskFactory Class
ContinueWhenAny Overload
System.Threading.Tasks Namespace


ContinueWhenAny(TAntecedentResult, TResult) Method (Task(TAntecedentResult)[], Func(Task(TAntecedentResult), TResult), TaskContinuationOptions)

[image]

.NET Framework Class Library
TaskFactory..::.ContinueWhenAny<(Of <(TAntecedentResult, TResult>)>) Method (array<Task<(Of <(TAntecedentResult>)>)>[]()[], Func<(Of <(Task<(Of <(TAntecedentResult>)>), TResult>)>), TaskContinuationOptions)
TaskFactory Class See Also Send Feedback

Creates a continuation Task that will be started upon the completion of any Task in the provided set.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Function ContinueWhenAny(Of TAntecedentResult, TResult) ( _
    tasks As Task(Of TAntecedentResult)(), _
    continuationFunction As Func(Of Task(Of TAntecedentResult), TResult), _
    continuationOptions As TaskContinuationOptions _
) As Task(Of TResult)
C#
public Task<TResult> ContinueWhenAny<TAntecedentResult, TResult>(
    Task<TAntecedentResult>[] tasks,
    Func<Task<TAntecedentResult>, TResult> continuationFunction,
    TaskContinuationOptions continuationOptions
)

Parameters

tasks
Type: array< System.Threading.Tasks..::.Task <(Of <(TAntecedentResult>)>) >[]()[]
The array of tasks from which to continue when one task completes.
continuationFunction
Type: System..::.Func<(Of <( Task <(Of <(TAntecedentResult>)>), TResult>)>)
The function delegate to execute when one task in the tasks array completes.
continuationOptions
Type: System.Threading.Tasks..::.TaskContinuationOptions
The TaskContinuationOptions value that controls the behavior of the created continuation Task.

Type Parameters

TAntecedentResult
The type of the result of the antecedent tasks.
TResult
The type of the result that is returned by the continuationFunction delegate and associated with the created Task<(Of <(TResult>)>).

Return Value

The new continuation Task<(Of <(TResult>)>).

Remarks

The NotOn* and OnlyOn* TaskContinuationOptions, which constrain for which TaskStatus states a continuation will be executed, are illegal with ContinueWhenAny.

Exceptions

Exception | Condition
System..::.ArgumentNullException | The exception that is thrown when the tasks array is null.
System..::.ArgumentNullException | The exception that is thrown when the continuationFunction argument is null.
System..::.ArgumentException | The exception that is thrown when the tasks array contains a null value.
System..::.ArgumentException | The exception that is thrown when the tasks array is empty.
System..::.ArgumentOutOfRangeException | The exception that is thrown when the continuationOptions argument specifies an invalid TaskContinuationOptions value.
System..::.ObjectDisposedException | The exception that is thrown when one of the elements in the tasks array has been disposed.

See Also

TaskFactory Class
ContinueWhenAny Overload
System.Threading.Tasks Namespace


ContinueWhenAny Method (Task[], Action(Task), CancellationToken, TaskContinuationOptions, TaskScheduler)

[image]

.NET Framework Class Library
TaskFactory..::.ContinueWhenAny Method (array<Task>[]()[], Action<(Of <(Task>)>), CancellationToken, TaskContinuationOptions, TaskScheduler)
TaskFactory Class See Also Send Feedback

Creates a continuation Task that will be started upon the completion of any Task in the provided set.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Function ContinueWhenAny ( _
    tasks As Task(), _
    continuationAction As Action(Of Task), _
    cancellationToken As CancellationToken, _
    continuationOptions As TaskContinuationOptions, _
    scheduler As TaskScheduler _
) As Task
C#
public Task ContinueWhenAny(
    Task[] tasks,
    Action<Task> continuationAction,
    CancellationToken cancellationToken,
    TaskContinuationOptions continuationOptions,
    TaskScheduler scheduler
)

Parameters

tasks
Type: array< System.Threading.Tasks..::.Task >[]()[]
The array of tasks from which to continue when one task completes.
continuationAction
Type: System..::.Action<(Of <( Task >)>)
The action delegate to execute when one task in the tasks array completes.
cancellationToken
Type: System.Threading..::.CancellationToken
The CancellationToken that will be assigned to the new continuation task.
continuationOptions
Type: System.Threading.Tasks..::.TaskContinuationOptions
The TaskContinuationOptions value that controls the behavior of the created continuation Task.
scheduler
Type: System.Threading.Tasks..::.TaskScheduler
The TaskScheduler that is used to schedule the created continuation Task.

Return Value

The new continuation Task.

Remarks

The NotOn* and OnlyOn* TaskContinuationOptions, which constrain for which TaskStatus states a continuation will be executed, are illegal with ContinueWhenAny.

Exceptions

Exception | Condition
System..::.ArgumentNullException | The exception that is thrown when the tasks array is null.
System..::.ArgumentNullException | The exception that is thrown when the continuationAction argument is null.
System..::.ArgumentNullException | The exception that is thrown when the scheduler argument is null.
System..::.ArgumentException | The exception that is thrown when the tasks array contains a null value.
System..::.ArgumentException | The exception that is thrown when the tasks array is empty.
System..::.ArgumentOutOfRangeException | The exception that is thrown when the continuationOptions argument specifies an invalid TaskContinuationOptions value.
System..::.ObjectDisposedException | The exception that is thrown when one of the elements in the tasks array has been disposed.
System..::.ObjectDisposedException | The provided CancellationToken has already been disposed.

See Also

TaskFactory Class
ContinueWhenAny Overload
System.Threading.Tasks Namespace


ContinueWhenAny(TResult) Method (Task[], Func(Task, TResult), CancellationToken, TaskContinuationOptions, TaskScheduler)

[image]

.NET Framework Class Library
TaskFactory..::.ContinueWhenAny<(Of <(TResult>)>) Method (array<Task>[]()[], Func<(Of <(Task, TResult>)>), CancellationToken, TaskContinuationOptions, TaskScheduler)
TaskFactory Class See Also Send Feedback

Creates a continuation Task that will be started upon the completion of any Task in the provided set.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Function ContinueWhenAny(Of TResult) ( _
    tasks As Task(), _
    continuationFunction As Func(Of Task, TResult), _
    cancellationToken As CancellationToken, _
    continuationOptions As TaskContinuationOptions, _
    scheduler As TaskScheduler _
) As Task(Of TResult)
C#
public Task<TResult> ContinueWhenAny<TResult>(
    Task[] tasks,
    Func<Task, TResult> continuationFunction,
    CancellationToken cancellationToken,
    TaskContinuationOptions continuationOptions,
    TaskScheduler scheduler
)

Parameters

tasks
Type: array< System.Threading.Tasks..::.Task >[]()[]
The array of tasks from which to continue when one task completes.
continuationFunction
Type: System..::.Func<(Of <( Task, TResult>)>)
The function delegate to execute when one task in the tasks array completes.
cancellationToken
Type: System.Threading..::.CancellationToken
The CancellationToken that will be assigned to the new continuation task.
continuationOptions
Type: System.Threading.Tasks..::.TaskContinuationOptions
The TaskContinuationOptions value that controls the behavior of the created continuation Task.
scheduler
Type: System.Threading.Tasks..::.TaskScheduler
The TaskScheduler that is used to schedule the created continuation Task<(Of <(TResult>)>).

Type Parameters

TResult
The type of the result that is returned by the continuationFunction delegate and associated with the created Task<(Of <(TResult>)>).

Return Value

The new continuation Task<(Of <(TResult>)>).

Remarks

The NotOn* and OnlyOn* TaskContinuationOptions, which constrain for which TaskStatus states a continuation will be executed, are illegal with ContinueWhenAny.

Exceptions

Exception | Condition
System..::.ArgumentNullException | The exception that is thrown when the tasks array is null.
System..::.ArgumentNullException | The exception that is thrown when the continuationFunction argument is null.
System..::.ArgumentNullException | The exception that is thrown when the scheduler argument is null.
System..::.ArgumentException | The exception that is thrown when the tasks array contains a null value.
System..::.ArgumentException | The exception that is thrown when the tasks array is empty.
System..::.ArgumentOutOfRangeException | The exception that is thrown when the continuationOptions argument specifies an invalid TaskContinuationOptions value.
System..::.ObjectDisposedException | The exception that is thrown when one of the elements in the tasks array has been disposed.
System..::.ObjectDisposedException | The provided CancellationToken has already been disposed.

See Also

TaskFactory Class
ContinueWhenAny Overload
System.Threading.Tasks Namespace


ContinueWhenAny(TAntecedentResult) Method (Task(TAntecedentResult)[], Action(Task(TAntecedentResult)), CancellationToken, TaskContinuationOptions, TaskScheduler)

[image]

.NET Framework Class Library
TaskFactory..::.ContinueWhenAny<(Of <(TAntecedentResult>)>) Method (array<Task<(Of <(TAntecedentResult>)>)>[]()[], Action<(Of <(Task<(Of <(TAntecedentResult>)>)>)>), CancellationToken, TaskContinuationOptions, TaskScheduler)
TaskFactory Class See Also Send Feedback

Creates a continuation Task that will be started upon the completion of any Task in the provided set.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Function ContinueWhenAny(Of TAntecedentResult) ( _
    tasks As Task(Of TAntecedentResult)(), _
    continuationAction As Action(Of Task(Of TAntecedentResult)), _
    cancellationToken As CancellationToken, _
    continuationOptions As TaskContinuationOptions, _
    scheduler As TaskScheduler _
) As Task
C#
public Task ContinueWhenAny<TAntecedentResult>(
    Task<TAntecedentResult>[] tasks,
    Action<Task<TAntecedentResult>> continuationAction,
    CancellationToken cancellationToken,
    TaskContinuationOptions continuationOptions,
    TaskScheduler scheduler
)

Parameters

tasks
Type: array< System.Threading.Tasks..::.Task <(Of <(TAntecedentResult>)>) >[]()[]
The array of tasks from which to continue when one task completes.
continuationAction
Type: System..::.Action<(Of <( Task <(Of <(TAntecedentResult>)>)>)>)
The action delegate to execute when one task in the tasks array completes.
cancellationToken
Type: System.Threading..::.CancellationToken
The CancellationToken that will be assigned to the new continuation task.
continuationOptions
Type: System.Threading.Tasks..::.TaskContinuationOptions
The TaskContinuationOptions value that controls the behavior of the created continuation Task.
scheduler
Type: System.Threading.Tasks..::.TaskScheduler
The TaskScheduler that is used to schedule the created continuation Task<(Of <(TResult>)>).

Type Parameters

TAntecedentResult
The type of the result of the antecedent tasks.

Return Value

The new continuation Task.

Remarks

The NotOn* and OnlyOn* TaskContinuationOptions, which constrain for which TaskStatus states a continuation will be executed, are illegal with ContinueWhenAny.

Exceptions

Exception | Condition
System..::.ArgumentNullException | The exception that is thrown when the tasks array is null.
System..::.ArgumentNullException | The exception that is thrown when the continuationAction argument is null.
System..::.ArgumentNullException | The exception that is thrown when the scheduler argument is null.
System..::.ArgumentException | The exception that is thrown when the tasks array contains a null value.
System..::.ArgumentException | The exception that is thrown when the tasks array is empty.
System..::.ArgumentOutOfRangeException | The exception that is thrown when the continuationOptions argument specifies an invalid TaskContinuationOptions value.
System..::.ObjectDisposedException | The exception that is thrown when one of the elements in the tasks array has been disposed.
System..::.ObjectDisposedException | The provided CancellationToken has already been disposed.

See Also

TaskFactory Class
ContinueWhenAny Overload
System.Threading.Tasks Namespace


ContinueWhenAny(TAntecedentResult, TResult) Method (Task(TAntecedentResult)[], Func(Task(TAntecedentResult), TResult), CancellationToken, TaskContinuationOptions, TaskScheduler)

[image]

.NET Framework Class Library
TaskFactory..::.ContinueWhenAny<(Of <(TAntecedentResult, TResult>)>) Method (array<Task<(Of <(TAntecedentResult>)>)>[]()[], Func<(Of <(Task<(Of <(TAntecedentResult>)>), TResult>)>), CancellationToken, TaskContinuationOptions, TaskScheduler)
TaskFactory Class See Also Send Feedback

Creates a continuation Task that will be started upon the completion of any Task in the provided set.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Function ContinueWhenAny(Of TAntecedentResult, TResult) ( _
    tasks As Task(Of TAntecedentResult)(), _
    continuationFunction As Func(Of Task(Of TAntecedentResult), TResult), _
    cancellationToken As CancellationToken, _
    continuationOptions As TaskContinuationOptions, _
    scheduler As TaskScheduler _
) As Task(Of TResult)
C#
public Task<TResult> ContinueWhenAny<TAntecedentResult, TResult>(
    Task<TAntecedentResult>[] tasks,
    Func<Task<TAntecedentResult>, TResult> continuationFunction,
    CancellationToken cancellationToken,
    TaskContinuationOptions continuationOptions,
    TaskScheduler scheduler
)

Parameters

tasks
Type: array< System.Threading.Tasks..::.Task <(Of <(TAntecedentResult>)>) >[]()[]
The array of tasks from which to continue when one task completes.
continuationFunction
Type: System..::.Func<(Of <( Task <(Of <(TAntecedentResult>)>), TResult>)>)
The function delegate to execute when one task in the tasks array completes.
cancellationToken
Type: System.Threading..::.CancellationToken
The CancellationToken that will be assigned to the new continuation task.
continuationOptions
Type: System.Threading.Tasks..::.TaskContinuationOptions
The TaskContinuationOptions value that controls the behavior of the created continuation Task.
scheduler
Type: System.Threading.Tasks..::.TaskScheduler
The TaskScheduler that is used to schedule the created continuation Task<(Of <(TResult>)>).

Type Parameters

TAntecedentResult
The type of the result of the antecedent tasks.
TResult
The type of the result that is returned by the continuationFunction delegate and associated with the created Task<(Of <(TResult>)>).

Return Value

The new continuation Task<(Of <(TResult>)>).

Remarks

The NotOn* and OnlyOn* TaskContinuationOptions, which constrain for which TaskStatus states a continuation will be executed, are illegal with ContinueWhenAny.

Exceptions

Exception | Condition
System..::.ArgumentNullException | The exception that is thrown when the tasks array is null.
System..::.ArgumentNullException | The exception that is thrown when the continuationFunction argument is null.
System..::.ArgumentNullException | The exception that is thrown when the scheduler argument is null.
System..::.ArgumentException | The exception that is thrown when the tasks array contains a null value.
System..::.ArgumentException | The exception that is thrown when the tasks array is empty.
System..::.ArgumentOutOfRangeException | The exception that is thrown when the continuationOptions argument specifies an invalid TaskContinuationOptions value.
System..::.ObjectDisposedException | The exception that is thrown when one of the elements in the tasks array has been disposed.
System..::.ObjectDisposedException | The provided CancellationToken has already been disposed.

See Also

TaskFactory Class
ContinueWhenAny Overload
System.Threading.Tasks Namespace


FromAsync Method

[image] [image]

.NET Framework Class Library
TaskFactory..::.FromAsync Method
TaskFactory Class See Also Send Feedback

Overload List

Name | Description
FromAsync(IAsyncResult, Action<(Of <(IAsyncResult>)>)) | Creates a Task that executes an end method action when a specified IAsyncResult completes.
FromAsync<(Of <(TResult>)>)(IAsyncResult, Func<(Of <(IAsyncResult, TResult>)>)) | Creates a Task that executes an end method function when a specified IAsyncResult completes.
FromAsync(Func<(Of <(AsyncCallback, Object, IAsyncResult>)>), Action<(Of <(IAsyncResult>)>), Object) | Creates a Task that represents a pair of begin and end methods that conform to the Asynchronous Programming Model pattern.
FromAsync<(Of <(TResult>)>)(Func<(Of <(AsyncCallback, Object, IAsyncResult>)>), Func<(Of <(IAsyncResult, TResult>)>), Object) | Creates a Task that represents a pair of begin and end methods that conform to the Asynchronous Programming Model pattern.
FromAsync(IAsyncResult, Action<(Of <(IAsyncResult>)>), TaskCreationOptions) | Creates a Task that executes an end method action when a specified IAsyncResult completes.
FromAsync<(Of <(TResult>)>)(IAsyncResult, Func<(Of <(IAsyncResult, TResult>)>), TaskCreationOptions) | Creates a Task that executes an end method function when a specified IAsyncResult completes.
FromAsync(Func<(Of <(AsyncCallback, Object, IAsyncResult>)>), Action<(Of <(IAsyncResult>)>), Object, TaskCreationOptions) | Creates a Task that represents a pair of begin and end methods that conform to the Asynchronous Programming Model pattern.
FromAsync<(Of <(TResult>)>)(Func<(Of <(AsyncCallback, Object, IAsyncResult>)>), Func<(Of <(IAsyncResult, TResult>)>), Object, TaskCreationOptions) | Creates a Task that represents a pair of begin and end methods that conform to the Asynchronous Programming Model pattern.
FromAsync<(Of <(TArg1>)>)(Func<(Of <(TArg1, AsyncCallback, Object, IAsyncResult>)>), Action<(Of <(IAsyncResult>)>), TArg1, Object) | Creates a Task that represents a pair of begin and end methods that conform to the Asynchronous Programming Model pattern.
FromAsync<(Of <(TArg1, TResult>)>)(Func<(Of <(TArg1, AsyncCallback, Object, IAsyncResult>)>), Func<(Of <(IAsyncResult, TResult>)>), TArg1, Object) | Creates a Task that represents a pair of begin and end methods that conform to the Asynchronous Programming Model pattern.
FromAsync(IAsyncResult, Action<(Of <(IAsyncResult>)>), TaskCreationOptions, TaskScheduler) | Creates a Task that executes an end method action when a specified IAsyncResult completes.
FromAsync<(Of <(TResult>)>)(IAsyncResult, Func<(Of <(IAsyncResult, TResult>)>), TaskCreationOptions, TaskScheduler) | Creates a Task that executes an end method function when a specified IAsyncResult completes.
FromAsync<(Of <(TArg1>)>)(Func<(Of <(TArg1, AsyncCallback, Object, IAsyncResult>)>), Action<(Of <(IAsyncResult>)>), TArg1, Object, TaskCreationOptions) | Creates a Task that represents a pair of begin and end methods that conform to the Asynchronous Programming Model pattern.
FromAsync<(Of <(TArg1, TResult>)>)(Func<(Of <(TArg1, AsyncCallback, Object, IAsyncResult>)>), Func<(Of <(IAsyncResult, TResult>)>), TArg1, Object, TaskCreationOptions) | Creates a Task that represents a pair of begin and end methods that conform to the Asynchronous Programming Model pattern.
FromAsync<(Of <(TArg1, TArg2>)>)(Func<(Of <(TArg1, TArg2, AsyncCallback, Object, IAsyncResult>)>), Action<(Of <(IAsyncResult>)>), TArg1, TArg2, Object) | Creates a Task that represents a pair of begin and end methods that conform to the Asynchronous Programming Model pattern.
FromAsync<(Of <(TArg1, TArg2, TResult>)>)(Func<(Of <(TArg1, TArg2, AsyncCallback, Object, IAsyncResult>)>), Func<(Of <(IAsyncResult, TResult>)>), TArg1, TArg2, Object) | Creates a Task that represents a pair of begin and end methods that conform to the Asynchronous Programming Model pattern.
FromAsync<(Of <(TArg1, TArg2, TArg3>)>)(Func_<(Of <(TArg1, TArg2, TArg3, AsyncCallback, Object, IAsyncResult>)>), Action<(Of <(IAsyncResult>)>), TArg1, TArg2, TArg3, Object) | Creates a Task that represents a pair of begin and end methods that conform to the Asynchronous Programming Model pattern.
FromAsync<(Of <(TArg1, TArg2, TArg3, TResult>)>)(Func_<(Of <(TArg1, TArg2, TArg3, AsyncCallback, Object, IAsyncResult>)>), Func<(Of <(IAsyncResult, TResult>)>), TArg1, TArg2, TArg3, Object) | Creates a Task that represents a pair of begin and end methods that conform to the Asynchronous Programming Model pattern.
FromAsync<(Of <(TArg1, TArg2>)>)(Func<(Of <(TArg1, TArg2, AsyncCallback, Object, IAsyncResult>)>), Action<(Of <(IAsyncResult>)>), TArg1, TArg2, Object, TaskCreationOptions) | Creates a Task that represents a pair of begin and end methods that conform to the Asynchronous Programming Model pattern.
FromAsync<(Of <(TArg1, TArg2, TResult>)>)(Func<(Of <(TArg1, TArg2, AsyncCallback, Object, IAsyncResult>)>), Func<(Of <(IAsyncResult, TResult>)>), TArg1, TArg2, Object, TaskCreationOptions) | Creates a Task that represents a pair of begin and end methods that conform to the Asynchronous Programming Model pattern.
FromAsync<(Of <(TArg1, TArg2, TArg3>)>)(Func_<(Of <(TArg1, TArg2, TArg3, AsyncCallback, Object, IAsyncResult>)>), Action<(Of <(IAsyncResult>)>), TArg1, TArg2, TArg3, Object, TaskCreationOptions) | Creates a Task that represents a pair of begin and end methods that conform to the Asynchronous Programming Model pattern.
FromAsync<(Of <(TArg1, TArg2, TArg3, TResult>)>)(Func_<(Of <(TArg1, TArg2, TArg3, AsyncCallback, Object, IAsyncResult>)>), Func<(Of <(IAsyncResult, TResult>)>), TArg1, TArg2, TArg3, Object, TaskCreationOptions) | Creates a Task that represents a pair of begin and end methods that conform to the Asynchronous Programming Model pattern.

See Also

TaskFactory Class
System.Threading.Tasks Namespace


FromAsync Method (IAsyncResult, Action(IAsyncResult))

[image]

.NET Framework Class Library
TaskFactory..::.FromAsync Method (IAsyncResult, Action<(Of <(IAsyncResult>)>))
TaskFactory Class See Also Send Feedback

Creates a Task that executes an end method action when a specified IAsyncResult completes.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Function FromAsync ( _
    asyncResult As IAsyncResult, _
    endMethod As Action(Of IAsyncResult) _
) As Task
C#
public Task FromAsync(
    IAsyncResult asyncResult,
    Action<IAsyncResult> endMethod
)

Parameters

asyncResult
Type: System..::.IAsyncResult
The IAsyncResult whose completion should trigger the processing of the endMethod.
endMethod
Type: System..::.Action<(Of <(IAsyncResult>)>)
The action delegate that processes the completed asyncResult.

Return Value

A Task that represents the asynchronous operation.

Exceptions

Exception | Condition
System..::.ArgumentNullException | The exception that is thrown when the asyncResult argument is null.
System..::.ArgumentNullException | The exception that is thrown when the endMethod argument is null.

See Also

TaskFactory Class
FromAsync Overload
System.Threading.Tasks Namespace


FromAsync(TResult) Method (IAsyncResult, Func(IAsyncResult, TResult))

[image]

.NET Framework Class Library
TaskFactory..::.FromAsync<(Of <(TResult>)>) Method (IAsyncResult, Func<(Of <(IAsyncResult, TResult>)>))
TaskFactory Class See Also Send Feedback

Creates a Task that executes an end method function when a specified IAsyncResult completes.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Function FromAsync(Of TResult) ( _
    asyncResult As IAsyncResult, _
    endMethod As Func(Of IAsyncResult, TResult) _
) As Task(Of TResult)
C#
public Task<TResult> FromAsync<TResult>(
    IAsyncResult asyncResult,
    Func<IAsyncResult, TResult> endMethod
)

Parameters

asyncResult
Type: System..::.IAsyncResult
The IAsyncResult whose completion should trigger the processing of the endMethod.
endMethod
Type: System..::.Func<(Of <(IAsyncResult, TResult>)>)
The function delegate that processes the completed asyncResult.

Type Parameters

TResult
The type of the result available through the Task.

Return Value

A Task that represents the asynchronous operation.

Exceptions

Exception | Condition
System..::.ArgumentNullException | The exception that is thrown when the asyncResult argument is null.
System..::.ArgumentNullException | The exception that is thrown when the endMethod argument is null.

See Also

TaskFactory Class
FromAsync Overload
System.Threading.Tasks Namespace


FromAsync Method (Func(AsyncCallback, Object, IAsyncResult), Action(IAsyncResult), Object)

[image]

.NET Framework Class Library
TaskFactory..::.FromAsync Method (Func<(Of <(AsyncCallback, Object, IAsyncResult>)>), Action<(Of <(IAsyncResult>)>), Object)
TaskFactory Class See Also Send Feedback

Creates a Task that represents a pair of begin and end methods that conform to the Asynchronous Programming Model pattern.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Function FromAsync ( _
    beginMethod As Func(Of AsyncCallback, Object, IAsyncResult), _
    endMethod As Action(Of IAsyncResult), _
    state As Object _
) As Task
C#
public Task FromAsync(
    Func<AsyncCallback, Object, IAsyncResult> beginMethod,
    Action<IAsyncResult> endMethod,
    Object state
)

Parameters

beginMethod
Type: System..::.Func<(Of <(AsyncCallback, Object, IAsyncResult>)>)
The delegate that begins the asynchronous operation.
endMethod
Type: System..::.Action<(Of <(IAsyncResult>)>)
The delegate that ends the asynchronous operation.
state
Type: System..::.Object
An object containing data to be used by the beginMethod delegate.

Return Value

The created Task that represents the asynchronous operation.

Remarks

This method throws any exceptions thrown by the beginMethod.

Exceptions

Exception | Condition
System..::.ArgumentNullException | The exception that is thrown when the beginMethod argument is null.
System..::.ArgumentNullException | The exception that is thrown when the endMethod argument is null.

See Also

TaskFactory Class
FromAsync Overload
System.Threading.Tasks Namespace


FromAsync(TResult) Method (Func(AsyncCallback, Object, IAsyncResult), Func(IAsyncResult, TResult), Object)

[image]

.NET Framework Class Library
TaskFactory..::.FromAsync<(Of <(TResult>)>) Method (Func<(Of <(AsyncCallback, Object, IAsyncResult>)>), Func<(Of <(IAsyncResult, TResult>)>), Object)
TaskFactory Class See Also Send Feedback

Creates a Task that represents a pair of begin and end methods that conform to the Asynchronous Programming Model pattern.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Function FromAsync(Of TResult) ( _
    beginMethod As Func(Of AsyncCallback, Object, IAsyncResult), _
    endMethod As Func(Of IAsyncResult, TResult), _
    state As Object _
) As Task(Of TResult)
C#
public Task<TResult> FromAsync<TResult>(
    Func<AsyncCallback, Object, IAsyncResult> beginMethod,
    Func<IAsyncResult, TResult> endMethod,
    Object state
)

Parameters

beginMethod
Type: System..::.Func<(Of <(AsyncCallback, Object, IAsyncResult>)>)
The delegate that begins the asynchronous operation.
endMethod
Type: System..::.Func<(Of <(IAsyncResult, TResult>)>)
The delegate that ends the asynchronous operation.
state
Type: System..::.Object
An object containing data to be used by the beginMethod delegate.

Type Parameters

TResult
The type of the result available through the Task.

Return Value

The created Task that represents the asynchronous operation.

Remarks

This method throws any exceptions thrown by the beginMethod.

Exceptions

Exception | Condition
System..::.ArgumentNullException | The exception that is thrown when the beginMethod argument is null.
System..::.ArgumentNullException | The exception that is thrown when the endMethod argument is null.

See Also

TaskFactory Class
FromAsync Overload
System.Threading.Tasks Namespace


FromAsync Method (IAsyncResult, Action(IAsyncResult), TaskCreationOptions)

[image]

.NET Framework Class Library
TaskFactory..::.FromAsync Method (IAsyncResult, Action<(Of <(IAsyncResult>)>), TaskCreationOptions)
TaskFactory Class See Also Send Feedback

Creates a Task that executes an end method action when a specified IAsyncResult completes.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Function FromAsync ( _
    asyncResult As IAsyncResult, _
    endMethod As Action(Of IAsyncResult), _
    creationOptions As TaskCreationOptions _
) As Task
C#
public Task FromAsync(
    IAsyncResult asyncResult,
    Action<IAsyncResult> endMethod,
    TaskCreationOptions creationOptions
)

Parameters

asyncResult
Type: System..::.IAsyncResult
The IAsyncResult whose completion should trigger the processing of the endMethod.
endMethod
Type: System..::.Action<(Of <(IAsyncResult>)>)
The action delegate that processes the completed asyncResult.
creationOptions
Type: System.Threading.Tasks..::.TaskCreationOptions
The TaskCreationOptions value that controls the behavior of the created Task.

Return Value

A Task that represents the asynchronous operation.

Exceptions

Exception | Condition
System..::.ArgumentNullException | The exception that is thrown when the asyncResult argument is null.
System..::.ArgumentNullException | The exception that is thrown when the endMethod argument is null.
System..::.ArgumentOutOfRangeException | The exception that is thrown when the creationOptions argument specifies an invalid TaskCreationOptions value.

See Also

TaskFactory Class
FromAsync Overload
System.Threading.Tasks Namespace


FromAsync(TResult) Method (IAsyncResult, Func(IAsyncResult, TResult), TaskCreationOptions)

[image]

.NET Framework Class Library
TaskFactory..::.FromAsync<(Of <(TResult>)>) Method (IAsyncResult, Func<(Of <(IAsyncResult, TResult>)>), TaskCreationOptions)
TaskFactory Class See Also Send Feedback

Creates a Task that executes an end method function when a specified IAsyncResult completes.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Function FromAsync(Of TResult) ( _
    asyncResult As IAsyncResult, _
    endMethod As Func(Of IAsyncResult, TResult), _
    creationOptions As TaskCreationOptions _
) As Task(Of TResult)
C#
public Task<TResult> FromAsync<TResult>(
    IAsyncResult asyncResult,
    Func<IAsyncResult, TResult> endMethod,
    TaskCreationOptions creationOptions
)

Parameters

asyncResult
Type: System..::.IAsyncResult
The IAsyncResult whose completion should trigger the processing of the endMethod.
endMethod
Type: System..::.Func<(Of <(IAsyncResult, TResult>)>)
The function delegate that processes the completed asyncResult.
creationOptions
Type: System.Threading.Tasks..::.TaskCreationOptions
The TaskCreationOptions value that controls the behavior of the created Task.

Type Parameters

TResult
The type of the result available through the Task.

Return Value

A Task that represents the asynchronous operation.

Exceptions

Exception | Condition
System..::.ArgumentNullException | The exception that is thrown when the asyncResult argument is null.
System..::.ArgumentNullException | The exception that is thrown when the endMethod argument is null.
System..::.ArgumentOutOfRangeException | The exception that is thrown when the creationOptions argument specifies an invalid TaskCreationOptions value.

See Also

TaskFactory Class
FromAsync Overload
System.Threading.Tasks Namespace


FromAsync Method (Func(AsyncCallback, Object, IAsyncResult), Action(IAsyncResult), Object, TaskCreationOptions)

[image]

.NET Framework Class Library
TaskFactory..::.FromAsync Method (Func<(Of <(AsyncCallback, Object, IAsyncResult>)>), Action<(Of <(IAsyncResult>)>), Object, TaskCreationOptions)
TaskFactory Class See Also Send Feedback

Creates a Task that represents a pair of begin and end methods that conform to the Asynchronous Programming Model pattern.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Function FromAsync ( _
    beginMethod As Func(Of AsyncCallback, Object, IAsyncResult), _
    endMethod As Action(Of IAsyncResult), _
    state As Object, _
    creationOptions As TaskCreationOptions _
) As Task
C#
public Task FromAsync(
    Func<AsyncCallback, Object, IAsyncResult> beginMethod,
    Action<IAsyncResult> endMethod,
    Object state,
    TaskCreationOptions creationOptions
)

Parameters

beginMethod
Type: System..::.Func<(Of <(AsyncCallback, Object, IAsyncResult>)>)
The delegate that begins the asynchronous operation.
endMethod
Type: System..::.Action<(Of <(IAsyncResult>)>)
The delegate that ends the asynchronous operation.
state
Type: System..::.Object
An object containing data to be used by the beginMethod delegate.
creationOptions
Type: System.Threading.Tasks..::.TaskCreationOptions
The TaskCreationOptions value that controls the behavior of the created Task.

Return Value

The created Task that represents the asynchronous operation.

Remarks

This method throws any exceptions thrown by the beginMethod.

Exceptions

Exception | Condition
System..::.ArgumentNullException | The exception that is thrown when the beginMethod argument is null.
System..::.ArgumentNullException | The exception that is thrown when the endMethod argument is null.
System..::.ArgumentOutOfRangeException | The exception that is thrown when the creationOptions argument specifies an invalid TaskCreationOptions value.

See Also

TaskFactory Class
FromAsync Overload
System.Threading.Tasks Namespace


FromAsync(TResult) Method (Func(AsyncCallback, Object, IAsyncResult), Func(IAsyncResult, TResult), Object, TaskCreationOptions)

[image]

.NET Framework Class Library
TaskFactory..::.FromAsync<(Of <(TResult>)>) Method (Func<(Of <(AsyncCallback, Object, IAsyncResult>)>), Func<(Of <(IAsyncResult, TResult>)>), Object, TaskCreationOptions)
TaskFactory Class See Also Send Feedback

Creates a Task that represents a pair of begin and end methods that conform to the Asynchronous Programming Model pattern.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Function FromAsync(Of TResult) ( _
    beginMethod As Func(Of AsyncCallback, Object, IAsyncResult), _
    endMethod As Func(Of IAsyncResult, TResult), _
    state As Object, _
    creationOptions As TaskCreationOptions _
) As Task(Of TResult)
C#
public Task<TResult> FromAsync<TResult>(
    Func<AsyncCallback, Object, IAsyncResult> beginMethod,
    Func<IAsyncResult, TResult> endMethod,
    Object state,
    TaskCreationOptions creationOptions
)

Parameters

beginMethod
Type: System..::.Func<(Of <(AsyncCallback, Object, IAsyncResult>)>)
The delegate that begins the asynchronous operation.
endMethod
Type: System..::.Func<(Of <(IAsyncResult, TResult>)>)
The delegate that ends the asynchronous operation.
state
Type: System..::.Object
An object containing data to be used by the beginMethod delegate.
creationOptions
Type: System.Threading.Tasks..::.TaskCreationOptions
The TaskCreationOptions value that controls the behavior of the created Task.

Type Parameters

TResult
The type of the result available through the Task.

Return Value

The created Task that represents the asynchronous operation.

Remarks

This method throws any exceptions thrown by the beginMethod.

Exceptions

Exception | Condition
System..::.ArgumentNullException | The exception that is thrown when the beginMethod argument is null.
System..::.ArgumentNullException | The exception that is thrown when the endMethod argument is null.
System..::.ArgumentOutOfRangeException | The exception that is thrown when the creationOptions argument specifies an invalid TaskCreationOptions value.

See Also

TaskFactory Class
FromAsync Overload
System.Threading.Tasks Namespace


FromAsync(TArg1) Method (Func(TArg1, AsyncCallback, Object, IAsyncResult), Action(IAsyncResult), TArg1, Object)

[image]

.NET Framework Class Library
TaskFactory..::.FromAsync<(Of <(TArg1>)>) Method (Func<(Of <(TArg1, AsyncCallback, Object, IAsyncResult>)>), Action<(Of <(IAsyncResult>)>), TArg1, Object)
TaskFactory Class See Also Send Feedback

Creates a Task that represents a pair of begin and end methods that conform to the Asynchronous Programming Model pattern.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Function FromAsync(Of TArg1) ( _
    beginMethod As Func(Of TArg1, AsyncCallback, Object, IAsyncResult), _
    endMethod As Action(Of IAsyncResult), _
    arg1 As TArg1, _
    state As Object _
) As Task
C#
public Task FromAsync<TArg1>(
    Func<TArg1, AsyncCallback, Object, IAsyncResult> beginMethod,
    Action<IAsyncResult> endMethod,
    TArg1 arg1,
    Object state
)

Parameters

beginMethod
Type: System..::.Func<(Of <(TArg1, AsyncCallback, Object, IAsyncResult>)>)
The delegate that begins the asynchronous operation.
endMethod
Type: System..::.Action<(Of <(IAsyncResult>)>)
The delegate that ends the asynchronous operation.
arg1
Type: TArg1
The first argument passed to the beginMethod delegate.
state
Type: System..::.Object
An object containing data to be used by the beginMethod delegate.

Type Parameters

TArg1
The type of the first argument passed to the beginMethod delegate.

Return Value

The created Task that represents the asynchronous operation.

Remarks

This method throws any exceptions thrown by the beginMethod.

Exceptions

Exception | Condition
System..::.ArgumentNullException | The exception that is thrown when the beginMethod argument is null.
System..::.ArgumentNullException | The exception that is thrown when the endMethod argument is null.

See Also

TaskFactory Class
FromAsync Overload
System.Threading.Tasks Namespace


FromAsync(TArg1, TResult) Method (Func(TArg1, AsyncCallback, Object, IAsyncResult), Func(IAsyncResult, TResult), TArg1, Object)

[image]

.NET Framework Class Library
TaskFactory..::.FromAsync<(Of <(TArg1, TResult>)>) Method (Func<(Of <(TArg1, AsyncCallback, Object, IAsyncResult>)>), Func<(Of <(IAsyncResult, TResult>)>), TArg1, Object)
TaskFactory Class See Also Send Feedback

Creates a Task that represents a pair of begin and end methods that conform to the Asynchronous Programming Model pattern.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Function FromAsync(Of TArg1, TResult) ( _
    beginMethod As Func(Of TArg1, AsyncCallback, Object, IAsyncResult), _
    endMethod As Func(Of IAsyncResult, TResult), _
    arg1 As TArg1, _
    state As Object _
) As Task(Of TResult)
C#
public Task<TResult> FromAsync<TArg1, TResult>(
    Func<TArg1, AsyncCallback, Object, IAsyncResult> beginMethod,
    Func<IAsyncResult, TResult> endMethod,
    TArg1 arg1,
    Object state
)

Parameters

beginMethod
Type: System..::.Func<(Of <(TArg1, AsyncCallback, Object, IAsyncResult>)>)
The delegate that begins the asynchronous operation.
endMethod
Type: System..::.Func<(Of <(IAsyncResult, TResult>)>)
The delegate that ends the asynchronous operation.
arg1
Type: TArg1
The first argument passed to the beginMethod delegate.
state
Type: System..::.Object
An object containing data to be used by the beginMethod delegate.

Type Parameters

TArg1
The type of the first argument passed to the beginMethod delegate.
TResult
The type of the result available through the Task.

Return Value

The created Task that represents the asynchronous operation.

Remarks

This method throws any exceptions thrown by the beginMethod.

Exceptions

Exception | Condition
System..::.ArgumentNullException | The exception that is thrown when the beginMethod argument is null.
System..::.ArgumentNullException | The exception that is thrown when the endMethod argument is null.

See Also

TaskFactory Class
FromAsync Overload
System.Threading.Tasks Namespace


FromAsync Method (IAsyncResult, Action(IAsyncResult), TaskCreationOptions, TaskScheduler)

[image]

.NET Framework Class Library
TaskFactory..::.FromAsync Method (IAsyncResult, Action<(Of <(IAsyncResult>)>), TaskCreationOptions, TaskScheduler)
TaskFactory Class See Also Send Feedback

Creates a Task that executes an end method action when a specified IAsyncResult completes.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Function FromAsync ( _
    asyncResult As IAsyncResult, _
    endMethod As Action(Of IAsyncResult), _
    creationOptions As TaskCreationOptions, _
    scheduler As TaskScheduler _
) As Task
C#
public Task FromAsync(
    IAsyncResult asyncResult,
    Action<IAsyncResult> endMethod,
    TaskCreationOptions creationOptions,
    TaskScheduler scheduler
)

Parameters

asyncResult
Type: System..::.IAsyncResult
The IAsyncResult whose completion should trigger the processing of the endMethod.
endMethod
Type: System..::.Action<(Of <(IAsyncResult>)>)
The action delegate that processes the completed asyncResult.
creationOptions
Type: System.Threading.Tasks..::.TaskCreationOptions
The TaskCreationOptions value that controls the behavior of the created Task.
scheduler
Type: System.Threading.Tasks..::.TaskScheduler
The TaskScheduler that is used to schedule the task that executes the end method.

Return Value

A Task that represents the asynchronous operation.

Exceptions

Exception | Condition
System..::.ArgumentNullException | The exception that is thrown when the asyncResult argument is null.
System..::.ArgumentNullException | The exception that is thrown when the endMethod argument is null.
System..::.ArgumentNullException | The exception that is thrown when the scheduler argument is null.
System..::.ArgumentOutOfRangeException | The exception that is thrown when the creationOptions argument specifies an invalid TaskCreationOptions value.

See Also

TaskFactory Class
FromAsync Overload
System.Threading.Tasks Namespace


FromAsync(TResult) Method (IAsyncResult, Func(IAsyncResult, TResult), TaskCreationOptions, TaskScheduler)

[image]

.NET Framework Class Library
TaskFactory..::.FromAsync<(Of <(TResult>)>) Method (IAsyncResult, Func<(Of <(IAsyncResult, TResult>)>), TaskCreationOptions, TaskScheduler)
TaskFactory Class See Also Send Feedback

Creates a Task that executes an end method function when a specified IAsyncResult completes.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Function FromAsync(Of TResult) ( _
    asyncResult As IAsyncResult, _
    endMethod As Func(Of IAsyncResult, TResult), _
    creationOptions As TaskCreationOptions, _
    scheduler As TaskScheduler _
) As Task(Of TResult)
C#
public Task<TResult> FromAsync<TResult>(
    IAsyncResult asyncResult,
    Func<IAsyncResult, TResult> endMethod,
    TaskCreationOptions creationOptions,
    TaskScheduler scheduler
)

Parameters

asyncResult
Type: System..::.IAsyncResult
The IAsyncResult whose completion should trigger the processing of the endMethod.
endMethod
Type: System..::.Func<(Of <(IAsyncResult, TResult>)>)
The function delegate that processes the completed asyncResult.
creationOptions
Type: System.Threading.Tasks..::.TaskCreationOptions
The TaskCreationOptions value that controls the behavior of the created Task.
scheduler
Type: System.Threading.Tasks..::.TaskScheduler
The TaskScheduler that is used to schedule the task that executes the end method.

Type Parameters

TResult
The type of the result available through the Task.

Return Value

A Task that represents the asynchronous operation.

Exceptions

Exception | Condition
System..::.ArgumentNullException | The exception that is thrown when the asyncResult argument is null.
System..::.ArgumentNullException | The exception that is thrown when the endMethod argument is null.
System..::.ArgumentNullException | The exception that is thrown when the scheduler argument is null.
System..::.ArgumentOutOfRangeException | The exception that is thrown when the creationOptions argument specifies an invalid TaskCreationOptions value.

See Also

TaskFactory Class
FromAsync Overload
System.Threading.Tasks Namespace


FromAsync(TArg1) Method (Func(TArg1, AsyncCallback, Object, IAsyncResult), Action(IAsyncResult), TArg1, Object, TaskCreationOptions)

[image]

.NET Framework Class Library
TaskFactory..::.FromAsync<(Of <(TArg1>)>) Method (Func<(Of <(TArg1, AsyncCallback, Object, IAsyncResult>)>), Action<(Of <(IAsyncResult>)>), TArg1, Object, TaskCreationOptions)
TaskFactory Class See Also Send Feedback

Creates a Task that represents a pair of begin and end methods that conform to the Asynchronous Programming Model pattern.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Function FromAsync(Of TArg1) ( _
    beginMethod As Func(Of TArg1, AsyncCallback, Object, IAsyncResult), _
    endMethod As Action(Of IAsyncResult), _
    arg1 As TArg1, _
    state As Object, _
    creationOptions As TaskCreationOptions _
) As Task
C#
public Task FromAsync<TArg1>(
    Func<TArg1, AsyncCallback, Object, IAsyncResult> beginMethod,
    Action<IAsyncResult> endMethod,
    TArg1 arg1,
    Object state,
    TaskCreationOptions creationOptions
)

Parameters

beginMethod
Type: System..::.Func<(Of <(TArg1, AsyncCallback, Object, IAsyncResult>)>)
The delegate that begins the asynchronous operation.
endMethod
Type: System..::.Action<(Of <(IAsyncResult>)>)
The delegate that ends the asynchronous operation.
arg1
Type: TArg1
The first argument passed to the beginMethod delegate.
state
Type: System..::.Object
An object containing data to be used by the beginMethod delegate.
creationOptions
Type: System.Threading.Tasks..::.TaskCreationOptions
The TaskCreationOptions value that controls the behavior of the created Task.

Type Parameters

TArg1
The type of the first argument passed to the beginMethod delegate.

Return Value

The created Task that represents the asynchronous operation.

Remarks

This method throws any exceptions thrown by the beginMethod.

Exceptions

Exception | Condition
System..::.ArgumentNullException | The exception that is thrown when the beginMethod argument is null.
System..::.ArgumentNullException | The exception that is thrown when the endMethod argument is null.
System..::.ArgumentOutOfRangeException | The exception that is thrown when the creationOptions argument specifies an invalid TaskCreationOptions value.

See Also

TaskFactory Class
FromAsync Overload
System.Threading.Tasks Namespace


FromAsync(TArg1, TResult) Method (Func(TArg1, AsyncCallback, Object, IAsyncResult), Func(IAsyncResult, TResult), TArg1, Object, TaskCreationOptions)

[image]

.NET Framework Class Library
TaskFactory..::.FromAsync<(Of <(TArg1, TResult>)>) Method (Func<(Of <(TArg1, AsyncCallback, Object, IAsyncResult>)>), Func<(Of <(IAsyncResult, TResult>)>), TArg1, Object, TaskCreationOptions)
TaskFactory Class See Also Send Feedback

Creates a Task that represents a pair of begin and end methods that conform to the Asynchronous Programming Model pattern.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Function FromAsync(Of TArg1, TResult) ( _
    beginMethod As Func(Of TArg1, AsyncCallback, Object, IAsyncResult), _
    endMethod As Func(Of IAsyncResult, TResult), _
    arg1 As TArg1, _
    state As Object, _
    creationOptions As TaskCreationOptions _
) As Task(Of TResult)
C#
public Task<TResult> FromAsync<TArg1, TResult>(
    Func<TArg1, AsyncCallback, Object, IAsyncResult> beginMethod,
    Func<IAsyncResult, TResult> endMethod,
    TArg1 arg1,
    Object state,
    TaskCreationOptions creationOptions
)

Parameters

beginMethod
Type: System..::.Func<(Of <(TArg1, AsyncCallback, Object, IAsyncResult>)>)
The delegate that begins the asynchronous operation.
endMethod
Type: System..::.Func<(Of <(IAsyncResult, TResult>)>)
The delegate that ends the asynchronous operation.
arg1
Type: TArg1
The first argument passed to the beginMethod delegate.
state
Type: System..::.Object
An object containing data to be used by the beginMethod delegate.
creationOptions
Type: System.Threading.Tasks..::.TaskCreationOptions
The TaskCreationOptions value that controls the behavior of the created Task.

Type Parameters

TArg1
The type of the first argument passed to the beginMethod delegate.
TResult
The type of the result available through the Task.

Return Value

The created Task that represents the asynchronous operation.

Remarks

This method throws any exceptions thrown by the beginMethod.

Exceptions

Exception | Condition
System..::.ArgumentNullException | The exception that is thrown when the beginMethod argument is null.
System..::.ArgumentNullException | The exception that is thrown when the endMethod argument is null.
System..::.ArgumentOutOfRangeException | The exception that is thrown when the creationOptions argument specifies an invalid TaskCreationOptions value.

See Also

TaskFactory Class
FromAsync Overload
System.Threading.Tasks Namespace


FromAsync(TArg1, TArg2) Method (Func(TArg1, TArg2, AsyncCallback, Object, IAsyncResult), Action(IAsyncResult), TArg1, TArg2, Object)

[image]

.NET Framework Class Library
TaskFactory..::.FromAsync<(Of <(TArg1, TArg2>)>) Method (Func<(Of <(TArg1, TArg2, AsyncCallback, Object, IAsyncResult>)>), Action<(Of <(IAsyncResult>)>), TArg1, TArg2, Object)
TaskFactory Class See Also Send Feedback

Creates a Task that represents a pair of begin and end methods that conform to the Asynchronous Programming Model pattern.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Function FromAsync(Of TArg1, TArg2) ( _
    beginMethod As Func(Of TArg1, TArg2, AsyncCallback, Object, IAsyncResult), _
    endMethod As Action(Of IAsyncResult), _
    arg1 As TArg1, _
    arg2 As TArg2, _
    state As Object _
) As Task
C#
public Task FromAsync<TArg1, TArg2>(
    Func<TArg1, TArg2, AsyncCallback, Object, IAsyncResult> beginMethod,
    Action<IAsyncResult> endMethod,
    TArg1 arg1,
    TArg2 arg2,
    Object state
)

Parameters

beginMethod
Type: System..::.Func<(Of <(TArg1, TArg2, AsyncCallback, Object, IAsyncResult>)>)
The delegate that begins the asynchronous operation.
endMethod
Type: System..::.Action<(Of <(IAsyncResult>)>)
The delegate that ends the asynchronous operation.
arg1
Type: TArg1
The first argument passed to the beginMethod delegate.
arg2
Type: TArg2
The second argument passed to the beginMethod delegate.
state
Type: System..::.Object
An object containing data to be used by the beginMethod delegate.

Type Parameters

TArg1
The type of the first argument passed to the beginMethod delegate.
TArg2
The type of the second argument passed to beginMethod delegate.

Return Value

The created Task that represents the asynchronous operation.

Remarks

This method throws any exceptions thrown by the beginMethod.

Exceptions

Exception | Condition
System..::.ArgumentNullException | The exception that is thrown when the beginMethod argument is null.
System..::.ArgumentNullException | The exception that is thrown when the endMethod argument is null.

See Also

TaskFactory Class
FromAsync Overload
System.Threading.Tasks Namespace


FromAsync(TArg1, TArg2, TResult) Method (Func(TArg1, TArg2, AsyncCallback, Object, IAsyncResult), Func(IAsyncResult, TResult), TArg1, TArg2, Object)

[image]

.NET Framework Class Library
TaskFactory..::.FromAsync<(Of <(TArg1, TArg2, TResult>)>) Method (Func<(Of <(TArg1, TArg2, AsyncCallback, Object, IAsyncResult>)>), Func<(Of <(IAsyncResult, TResult>)>), TArg1, TArg2, Object)
TaskFactory Class See Also Send Feedback

Creates a Task that represents a pair of begin and end methods that conform to the Asynchronous Programming Model pattern.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Function FromAsync(Of TArg1, TArg2, TResult) ( _
    beginMethod As Func(Of TArg1, TArg2, AsyncCallback, Object, IAsyncResult), _
    endMethod As Func(Of IAsyncResult, TResult), _
    arg1 As TArg1, _
    arg2 As TArg2, _
    state As Object _
) As Task(Of TResult)
C#
public Task<TResult> FromAsync<TArg1, TArg2, TResult>(
    Func<TArg1, TArg2, AsyncCallback, Object, IAsyncResult> beginMethod,
    Func<IAsyncResult, TResult> endMethod,
    TArg1 arg1,
    TArg2 arg2,
    Object state
)

Parameters

beginMethod
Type: System..::.Func<(Of <(TArg1, TArg2, AsyncCallback, Object, IAsyncResult>)>)
The delegate that begins the asynchronous operation.
endMethod
Type: System..::.Func<(Of <(IAsyncResult, TResult>)>)
The delegate that ends the asynchronous operation.
arg1
Type: TArg1
The first argument passed to the beginMethod delegate.
arg2
Type: TArg2
The second argument passed to the beginMethod delegate.
state
Type: System..::.Object
An object containing data to be used by the beginMethod delegate.

Type Parameters

TArg1
The type of the first argument passed to the beginMethod delegate.
TArg2
The type of the second argument passed to beginMethod delegate.
TResult
The type of the result available through the Task.

Return Value

The created Task that represents the asynchronous operation.

Remarks

This method throws any exceptions thrown by the beginMethod.

Exceptions

Exception | Condition
System..::.ArgumentNullException | The exception that is thrown when the beginMethod argument is null.
System..::.ArgumentNullException | The exception that is thrown when the endMethod argument is null.

See Also

TaskFactory Class
FromAsync Overload
System.Threading.Tasks Namespace


FromAsync(TArg1, TArg2, TArg3) Method (Func_(TArg1, TArg2, TArg3, AsyncCallback, Object, IAsyncResult), Action(IAsyncResult), TArg1, TArg2, TArg3, Object)

[image]

.NET Framework Class Library
TaskFactory..::.FromAsync<(Of <(TArg1, TArg2, TArg3>)>) Method (Func_<(Of <(TArg1, TArg2, TArg3, AsyncCallback, Object, IAsyncResult>)>), Action<(Of <(IAsyncResult>)>), TArg1, TArg2, TArg3, Object)
TaskFactory Class See Also Send Feedback

Creates a Task that represents a pair of begin and end methods that conform to the Asynchronous Programming Model pattern.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Function FromAsync(Of TArg1, TArg2, TArg3) ( _
    beginMethod As Func_(Of TArg1, TArg2, TArg3, AsyncCallback, Object, IAsyncResult), _
    endMethod As Action(Of IAsyncResult), _
    arg1 As TArg1, _
    arg2 As TArg2, _
    arg3 As TArg3, _
    state As Object _
) As Task
C#
public Task FromAsync<TArg1, TArg2, TArg3>(
    Func_<TArg1, TArg2, TArg3, AsyncCallback, Object, IAsyncResult> beginMethod,
    Action<IAsyncResult> endMethod,
    TArg1 arg1,
    TArg2 arg2,
    TArg3 arg3,
    Object state
)

Parameters

beginMethod
Type: System..::.Func_ <(Of <(TArg1, TArg2, TArg3, AsyncCallback, Object, IAsyncResult>)>)
The delegate that begins the asynchronous operation.
endMethod
Type: System..::.Action<(Of <(IAsyncResult>)>)
The delegate that ends the asynchronous operation.
arg1
Type: TArg1
The first argument passed to the beginMethod delegate.
arg2
Type: TArg2
The second argument passed to the beginMethod delegate.
arg3
Type: TArg3
The third argument passed to the beginMethod delegate.
state
Type: System..::.Object
An object containing data to be used by the beginMethod delegate.

Type Parameters

TArg1
The type of the first argument passed to the beginMethod delegate.
TArg2
The type of the second argument passed to beginMethod delegate.
TArg3
The type of the third argument passed to beginMethod delegate.

Return Value

The created Task that represents the asynchronous operation.

Remarks

This method throws any exceptions thrown by the beginMethod.

Exceptions

Exception | Condition
System..::.ArgumentNullException | The exception that is thrown when the beginMethod argument is null.
System..::.ArgumentNullException | The exception that is thrown when the endMethod argument is null.

See Also

TaskFactory Class
FromAsync Overload
System.Threading.Tasks Namespace


FromAsync(TArg1, TArg2, TArg3, TResult) Method (Func_(TArg1, TArg2, TArg3, AsyncCallback, Object, IAsyncResult), Func(IAsyncResult, TResult), TArg1, TArg2, TArg3, Object)

[image]

.NET Framework Class Library
TaskFactory..::.FromAsync<(Of <(TArg1, TArg2, TArg3, TResult>)>) Method (Func_<(Of <(TArg1, TArg2, TArg3, AsyncCallback, Object, IAsyncResult>)>), Func<(Of <(IAsyncResult, TResult>)>), TArg1, TArg2, TArg3, Object)
TaskFactory Class See Also Send Feedback

Creates a Task that represents a pair of begin and end methods that conform to the Asynchronous Programming Model pattern.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Function FromAsync(Of TArg1, TArg2, TArg3, TResult) ( _
    beginMethod As Func_(Of TArg1, TArg2, TArg3, AsyncCallback, Object, IAsyncResult), _
    endMethod As Func(Of IAsyncResult, TResult), _
    arg1 As TArg1, _
    arg2 As TArg2, _
    arg3 As TArg3, _
    state As Object _
) As Task(Of TResult)
C#
public Task<TResult> FromAsync<TArg1, TArg2, TArg3, TResult>(
    Func_<TArg1, TArg2, TArg3, AsyncCallback, Object, IAsyncResult> beginMethod,
    Func<IAsyncResult, TResult> endMethod,
    TArg1 arg1,
    TArg2 arg2,
    TArg3 arg3,
    Object state
)

Parameters

beginMethod
Type: System..::.Func_ <(Of <(TArg1, TArg2, TArg3, AsyncCallback, Object, IAsyncResult>)>)
The delegate that begins the asynchronous operation.
endMethod
Type: System..::.Func<(Of <(IAsyncResult, TResult>)>)
The delegate that ends the asynchronous operation.
arg1
Type: TArg1
The first argument passed to the beginMethod delegate.
arg2
Type: TArg2
The second argument passed to the beginMethod delegate.
arg3
Type: TArg3
The third argument passed to the beginMethod delegate.
state
Type: System..::.Object
An object containing data to be used by the beginMethod delegate.

Type Parameters

TArg1
The type of the first argument passed to the beginMethod delegate.
TArg2
The type of the second argument passed to beginMethod delegate.
TArg3
The type of the third argument passed to beginMethod delegate.
TResult
The type of the result available through the Task.

Return Value

The created Task that represents the asynchronous operation.

Remarks

This method throws any exceptions thrown by the beginMethod.

Exceptions

Exception | Condition
System..::.ArgumentNullException | The exception that is thrown when the beginMethod argument is null.
System..::.ArgumentNullException | The exception that is thrown when the endMethod argument is null.

See Also

TaskFactory Class
FromAsync Overload
System.Threading.Tasks Namespace


FromAsync(TArg1, TArg2) Method (Func(TArg1, TArg2, AsyncCallback, Object, IAsyncResult), Action(IAsyncResult), TArg1, TArg2, Object, TaskCreationOptions)

[image]

.NET Framework Class Library
TaskFactory..::.FromAsync<(Of <(TArg1, TArg2>)>) Method (Func<(Of <(TArg1, TArg2, AsyncCallback, Object, IAsyncResult>)>), Action<(Of <(IAsyncResult>)>), TArg1, TArg2, Object, TaskCreationOptions)
TaskFactory Class See Also Send Feedback

Creates a Task that represents a pair of begin and end methods that conform to the Asynchronous Programming Model pattern.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Function FromAsync(Of TArg1, TArg2) ( _
    beginMethod As Func(Of TArg1, TArg2, AsyncCallback, Object, IAsyncResult), _
    endMethod As Action(Of IAsyncResult), _
    arg1 As TArg1, _
    arg2 As TArg2, _
    state As Object, _
    creationOptions As TaskCreationOptions _
) As Task
C#
public Task FromAsync<TArg1, TArg2>(
    Func<TArg1, TArg2, AsyncCallback, Object, IAsyncResult> beginMethod,
    Action<IAsyncResult> endMethod,
    TArg1 arg1,
    TArg2 arg2,
    Object state,
    TaskCreationOptions creationOptions
)

Parameters

beginMethod
Type: System..::.Func<(Of <(TArg1, TArg2, AsyncCallback, Object, IAsyncResult>)>)
The delegate that begins the asynchronous operation.
endMethod
Type: System..::.Action<(Of <(IAsyncResult>)>)
The delegate that ends the asynchronous operation.
arg1
Type: TArg1
The first argument passed to the beginMethod delegate.
arg2
Type: TArg2
The second argument passed to the beginMethod delegate.
state
Type: System..::.Object
An object containing data to be used by the beginMethod delegate.
creationOptions
Type: System.Threading.Tasks..::.TaskCreationOptions
The TaskCreationOptions value that controls the behavior of the created Task.

Type Parameters

TArg1
The type of the first argument passed to the beginMethod delegate.
TArg2
The type of the second argument passed to beginMethod delegate.

Return Value

The created Task that represents the asynchronous operation.

Remarks

This method throws any exceptions thrown by the beginMethod.

Exceptions

Exception | Condition
System..::.ArgumentNullException | The exception that is thrown when the beginMethod argument is null.
System..::.ArgumentNullException | The exception that is thrown when the endMethod argument is null.
System..::.ArgumentOutOfRangeException | The exception that is thrown when the creationOptions argument specifies an invalid TaskCreationOptions value.

See Also

TaskFactory Class
FromAsync Overload
System.Threading.Tasks Namespace


FromAsync(TArg1, TArg2, TResult) Method (Func(TArg1, TArg2, AsyncCallback, Object, IAsyncResult), Func(IAsyncResult, TResult), TArg1, TArg2, Object, TaskCreationOptions)

[image]

.NET Framework Class Library
TaskFactory..::.FromAsync<(Of <(TArg1, TArg2, TResult>)>) Method (Func<(Of <(TArg1, TArg2, AsyncCallback, Object, IAsyncResult>)>), Func<(Of <(IAsyncResult, TResult>)>), TArg1, TArg2, Object, TaskCreationOptions)
TaskFactory Class See Also Send Feedback

Creates a Task that represents a pair of begin and end methods that conform to the Asynchronous Programming Model pattern.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Function FromAsync(Of TArg1, TArg2, TResult) ( _
    beginMethod As Func(Of TArg1, TArg2, AsyncCallback, Object, IAsyncResult), _
    endMethod As Func(Of IAsyncResult, TResult), _
    arg1 As TArg1, _
    arg2 As TArg2, _
    state As Object, _
    creationOptions As TaskCreationOptions _
) As Task(Of TResult)
C#
public Task<TResult> FromAsync<TArg1, TArg2, TResult>(
    Func<TArg1, TArg2, AsyncCallback, Object, IAsyncResult> beginMethod,
    Func<IAsyncResult, TResult> endMethod,
    TArg1 arg1,
    TArg2 arg2,
    Object state,
    TaskCreationOptions creationOptions
)

Parameters

beginMethod
Type: System..::.Func<(Of <(TArg1, TArg2, AsyncCallback, Object, IAsyncResult>)>)
The delegate that begins the asynchronous operation.
endMethod
Type: System..::.Func<(Of <(IAsyncResult, TResult>)>)
The delegate that ends the asynchronous operation.
arg1
Type: TArg1
The first argument passed to the beginMethod delegate.
arg2
Type: TArg2
The second argument passed to the beginMethod delegate.
state
Type: System..::.Object
An object containing data to be used by the beginMethod delegate.
creationOptions
Type: System.Threading.Tasks..::.TaskCreationOptions
The TaskCreationOptions value that controls the behavior of the created Task.

Type Parameters

TArg1
The type of the first argument passed to the beginMethod delegate.
TArg2
The type of the second argument passed to beginMethod delegate.
TResult
The type of the result available through the Task.

Return Value

The created Task that represents the asynchronous operation.

Remarks

This method throws any exceptions thrown by the beginMethod.

Exceptions

Exception | Condition
System..::.ArgumentNullException | The exception that is thrown when the beginMethod argument is null.
System..::.ArgumentNullException | The exception that is thrown when the endMethod argument is null.
System..::.ArgumentOutOfRangeException | The exception that is thrown when the creationOptions argument specifies an invalid TaskCreationOptions value.

See Also

TaskFactory Class
FromAsync Overload
System.Threading.Tasks Namespace


FromAsync(TArg1, TArg2, TArg3) Method (Func_(TArg1, TArg2, TArg3, AsyncCallback, Object, IAsyncResult), Action(IAsyncResult), TArg1, TArg2, TArg3, Object, TaskCreationOptions)

[image]

.NET Framework Class Library
TaskFactory..::.FromAsync<(Of <(TArg1, TArg2, TArg3>)>) Method (Func_<(Of <(TArg1, TArg2, TArg3, AsyncCallback, Object, IAsyncResult>)>), Action<(Of <(IAsyncResult>)>), TArg1, TArg2, TArg3, Object, TaskCreationOptions)
TaskFactory Class See Also Send Feedback

Creates a Task that represents a pair of begin and end methods that conform to the Asynchronous Programming Model pattern.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Function FromAsync(Of TArg1, TArg2, TArg3) ( _
    beginMethod As Func_(Of TArg1, TArg2, TArg3, AsyncCallback, Object, IAsyncResult), _
    endMethod As Action(Of IAsyncResult), _
    arg1 As TArg1, _
    arg2 As TArg2, _
    arg3 As TArg3, _
    state As Object, _
    creationOptions As TaskCreationOptions _
) As Task
C#
public Task FromAsync<TArg1, TArg2, TArg3>(
    Func_<TArg1, TArg2, TArg3, AsyncCallback, Object, IAsyncResult> beginMethod,
    Action<IAsyncResult> endMethod,
    TArg1 arg1,
    TArg2 arg2,
    TArg3 arg3,
    Object state,
    TaskCreationOptions creationOptions
)

Parameters

beginMethod
Type: System..::.Func_ <(Of <(TArg1, TArg2, TArg3, AsyncCallback, Object, IAsyncResult>)>)
The delegate that begins the asynchronous operation.
endMethod
Type: System..::.Action<(Of <(IAsyncResult>)>)
The delegate that ends the asynchronous operation.
arg1
Type: TArg1
The first argument passed to the beginMethod delegate.
arg2
Type: TArg2
The second argument passed to the beginMethod delegate.
arg3
Type: TArg3
The third argument passed to the beginMethod delegate.
state
Type: System..::.Object
An object containing data to be used by the beginMethod delegate.
creationOptions
Type: System.Threading.Tasks..::.TaskCreationOptions
The TaskCreationOptions value that controls the behavior of the created Task.

Type Parameters

TArg1
The type of the first argument passed to the beginMethod delegate.
TArg2
The type of the second argument passed to beginMethod delegate.
TArg3
The type of the third argument passed to beginMethod delegate.

Return Value

The created Task that represents the asynchronous operation.

Remarks

This method throws any exceptions thrown by the beginMethod.

Exceptions

Exception | Condition
System..::.ArgumentNullException | The exception that is thrown when the beginMethod argument is null.
System..::.ArgumentNullException | The exception that is thrown when the endMethod argument is null.
System..::.ArgumentOutOfRangeException | The exception that is thrown when the creationOptions argument specifies an invalid TaskCreationOptions value.

See Also

TaskFactory Class
FromAsync Overload
System.Threading.Tasks Namespace


FromAsync(TArg1, TArg2, TArg3, TResult) Method (Func_(TArg1, TArg2, TArg3, AsyncCallback, Object, IAsyncResult), Func(IAsyncResult, TResult), TArg1, TArg2, TArg3, Object, TaskCreationOptions)

[image]

.NET Framework Class Library
TaskFactory..::.FromAsync<(Of <(TArg1, TArg2, TArg3, TResult>)>) Method (Func_<(Of <(TArg1, TArg2, TArg3, AsyncCallback, Object, IAsyncResult>)>), Func<(Of <(IAsyncResult, TResult>)>), TArg1, TArg2, TArg3, Object, TaskCreationOptions)
TaskFactory Class See Also Send Feedback

Creates a Task that represents a pair of begin and end methods that conform to the Asynchronous Programming Model pattern.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Function FromAsync(Of TArg1, TArg2, TArg3, TResult) ( _
    beginMethod As Func_(Of TArg1, TArg2, TArg3, AsyncCallback, Object, IAsyncResult), _
    endMethod As Func(Of IAsyncResult, TResult), _
    arg1 As TArg1, _
    arg2 As TArg2, _
    arg3 As TArg3, _
    state As Object, _
    creationOptions As TaskCreationOptions _
) As Task(Of TResult)
C#
public Task<TResult> FromAsync<TArg1, TArg2, TArg3, TResult>(
    Func_<TArg1, TArg2, TArg3, AsyncCallback, Object, IAsyncResult> beginMethod,
    Func<IAsyncResult, TResult> endMethod,
    TArg1 arg1,
    TArg2 arg2,
    TArg3 arg3,
    Object state,
    TaskCreationOptions creationOptions
)

Parameters

beginMethod
Type: System..::.Func_ <(Of <(TArg1, TArg2, TArg3, AsyncCallback, Object, IAsyncResult>)>)
The delegate that begins the asynchronous operation.
endMethod
Type: System..::.Func<(Of <(IAsyncResult, TResult>)>)
The delegate that ends the asynchronous operation.
arg1
Type: TArg1
The first argument passed to the beginMethod delegate.
arg2
Type: TArg2
The second argument passed to the beginMethod delegate.
arg3
Type: TArg3
The third argument passed to the beginMethod delegate.
state
Type: System..::.Object
An object containing data to be used by the beginMethod delegate.
creationOptions
Type: System.Threading.Tasks..::.TaskCreationOptions
The TaskCreationOptions value that controls the behavior of the created Task.

Type Parameters

TArg1
The type of the first argument passed to the beginMethod delegate.
TArg2
The type of the second argument passed to beginMethod delegate.
TArg3
The type of the third argument passed to beginMethod delegate.
TResult
The type of the result available through the Task.

Return Value

The created Task that represents the asynchronous operation.

Remarks

This method throws any exceptions thrown by the beginMethod.

Exceptions

Exception | Condition
System..::.ArgumentNullException | The exception that is thrown when the beginMethod argument is null.
System..::.ArgumentNullException | The exception that is thrown when the endMethod argument is null.
System..::.ArgumentOutOfRangeException | The exception that is thrown when the creationOptions argument specifies an invalid TaskCreationOptions value.

See Also

TaskFactory Class
FromAsync Overload
System.Threading.Tasks Namespace


StartNew Method

[image] [image]

.NET Framework Class Library
TaskFactory..::.StartNew Method
TaskFactory Class See Also Send Feedback

Overload List

Name | Description
StartNew(Action) | Creates and starts a Task.
StartNew<(Of <(TResult>)>)(Func<(Of <(TResult>)>)) | Creates and starts a Task<(Of <(TResult>)>).
StartNew(Action, CancellationToken) | Creates and starts a Task.
StartNew(Action, TaskCreationOptions) | Creates and starts a Task.
StartNew(Action<(Of <(Object>)>), Object) | Creates and starts a Task.
StartNew<(Of <(TResult>)>)(Func<(Of <(TResult>)>), CancellationToken) | Creates and starts a Task<(Of <(TResult>)>).
StartNew<(Of <(TResult>)>)(Func<(Of <(TResult>)>), TaskCreationOptions) | Creates and starts a Task<(Of <(TResult>)>).
StartNew<(Of <(TResult>)>)(Func<(Of <(Object, TResult>)>), Object) | Creates and starts a Task<(Of <(TResult>)>).
StartNew(Action<(Of <(Object>)>), Object, CancellationToken) | Creates and starts a Task.
StartNew(Action<(Of <(Object>)>), Object, TaskCreationOptions) | Creates and starts a Task.
StartNew<(Of <(TResult>)>)(Func<(Of <(Object, TResult>)>), Object, CancellationToken) | Creates and starts a Task<(Of <(TResult>)>).
StartNew<(Of <(TResult>)>)(Func<(Of <(Object, TResult>)>), Object, TaskCreationOptions) | Creates and starts a Task<(Of <(TResult>)>).
StartNew(Action, CancellationToken, TaskCreationOptions, TaskScheduler) | Creates and starts a Task.
StartNew<(Of <(TResult>)>)(Func<(Of <(TResult>)>), CancellationToken, TaskCreationOptions, TaskScheduler) | Creates and starts a Task<(Of <(TResult>)>).
StartNew(Action<(Of <(Object>)>), Object, CancellationToken, TaskCreationOptions, TaskScheduler) | Creates and starts a Task.
StartNew<(Of <(TResult>)>)(Func<(Of <(Object, TResult>)>), Object, CancellationToken, TaskCreationOptions, TaskScheduler) | Creates and starts a Task<(Of <(TResult>)>).

See Also

TaskFactory Class
System.Threading.Tasks Namespace


StartNew Method (Action)

[image]

.NET Framework Class Library
TaskFactory..::.StartNew Method (Action)
TaskFactory Class See Also Send Feedback

Creates and starts a Task.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Function StartNew ( _
    action As Action _
) As Task
C#
public Task StartNew(
    Action action
)

Parameters

action
Type: System..::.Action
The action delegate to execute asynchronously.

Return Value

The started Task.

Remarks

Calling StartNew is functionally equivalent to creating a Task using one of its constructors and then calling Start to schedule it for execution. However, unless creation and scheduling must be separated, StartNew is the recommended approach for both simplicity and performance.

Exceptions

Exception | Condition
System..::.ArgumentNullException | The exception that is thrown when the action argument is null.

See Also

TaskFactory Class
StartNew Overload
System.Threading.Tasks Namespace


StartNew(TResult) Method (Func(TResult))

[image]

.NET Framework Class Library
TaskFactory..::.StartNew<(Of <(TResult>)>) Method (Func<(Of <(TResult>)>))
TaskFactory Class See Also Send Feedback

Creates and starts a Task<(Of <(TResult>)>).

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Function StartNew(Of TResult) ( _
    function As Func(Of TResult) _
) As Task(Of TResult)
C#
public Task<TResult> StartNew<TResult>(
    Func<TResult> function
)

Parameters

function
Type: System..::.Func<(Of <(TResult>)>)
A function delegate that returns the future result to be available through the Task<(Of <(TResult>)>).

Type Parameters

TResult
The type of the result available through the Task.

Return Value

The started Task<(Of <(TResult>)>).

Remarks

Calling StartNew is functionally equivalent to creating a Task<(Of <(TResult>)>) using one of its constructors and then calling Start to schedule it for execution. However, unless creation and scheduling must be separated, StartNew is the recommended approach for both simplicity and performance.

Exceptions

Exception | Condition
System..::.ArgumentNullException | The exception that is thrown when the function argument is null.

See Also

TaskFactory Class
StartNew Overload
System.Threading.Tasks Namespace


StartNew Method (Action, CancellationToken)

[image]

.NET Framework Class Library
TaskFactory..::.StartNew Method (Action, CancellationToken)
TaskFactory Class See Also Send Feedback

Creates and starts a Task.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Function StartNew ( _
    action As Action, _
    cancellationToken As CancellationToken _
) As Task
C#
public Task StartNew(
    Action action,
    CancellationToken cancellationToken
)

Parameters

action
Type: System..::.Action
The action delegate to execute asynchronously.
cancellationToken
Type: System.Threading..::.CancellationToken
The CancellationToken that will be assigned to the new task.

Return Value

The started Task.

Remarks

Calling StartNew is functionally equivalent to creating a Task using one of its constructors and then calling Start to schedule it for execution. However, unless creation and scheduling must be separated, StartNew is the recommended approach for both simplicity and performance.

Exceptions

Exception | Condition
System..::.ArgumentNullException | The exception that is thrown when the action argument is null.
System..::.ObjectDisposedException | The provided CancellationToken has already been disposed.

See Also

TaskFactory Class
StartNew Overload
System.Threading.Tasks Namespace


StartNew Method (Action, TaskCreationOptions)

[image]

.NET Framework Class Library
TaskFactory..::.StartNew Method (Action, TaskCreationOptions)
TaskFactory Class See Also Send Feedback

Creates and starts a Task.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Function StartNew ( _
    action As Action, _
    creationOptions As TaskCreationOptions _
) As Task
C#
public Task StartNew(
    Action action,
    TaskCreationOptions creationOptions
)

Parameters

action
Type: System..::.Action
The action delegate to execute asynchronously.
creationOptions
Type: System.Threading.Tasks..::.TaskCreationOptions
A TaskCreationOptions value that controls the behavior of the created Task.

Return Value

The started Task.

Remarks

Calling StartNew is functionally equivalent to creating a Task using one of its constructors and then calling Start to schedule it for execution. However, unless creation and scheduling must be separated, StartNew is the recommended approach for both simplicity and performance.

Exceptions

Exception | Condition
System..::.ArgumentNullException | The exception that is thrown when the action argument is null.
System..::.ArgumentOutOfRangeException | The exception that is thrown when the creationOptions argument specifies an invalid TaskCreationOptions value.

See Also

TaskFactory Class
StartNew Overload
System.Threading.Tasks Namespace


StartNew Method (Action(Object), Object)

[image]

.NET Framework Class Library
TaskFactory..::.StartNew Method (Action<(Of <(Object>)>), Object)
TaskFactory Class See Also Send Feedback

Creates and starts a Task.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Function StartNew ( _
    action As Action(Of Object), _
    state As Object _
) As Task
C#
public Task StartNew(
    Action<Object> action,
    Object state
)

Parameters

action
Type: System..::.Action<(Of <(Object>)>)
The action delegate to execute asynchronously.
state
Type: System..::.Object
An object containing data to be used by the action delegate.

Return Value

The started Task.

Remarks

Calling StartNew is functionally equivalent to creating a Task using one of its constructors and then calling Start to schedule it for execution. However, unless creation and scheduling must be separated, StartNew is the recommended approach for both simplicity and performance.

Exceptions

Exception | Condition
System..::.ArgumentNullException | The exception that is thrown when the action argument is null.

See Also

TaskFactory Class
StartNew Overload
System.Threading.Tasks Namespace


StartNew(TResult) Method (Func(TResult), CancellationToken)

[image]

.NET Framework Class Library
TaskFactory..::.StartNew<(Of <(TResult>)>) Method (Func<(Of <(TResult>)>), CancellationToken)
TaskFactory Class See Also Send Feedback

Creates and starts a Task<(Of <(TResult>)>).

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Function StartNew(Of TResult) ( _
    function As Func(Of TResult), _
    cancellationToken As CancellationToken _
) As Task(Of TResult)
C#
public Task<TResult> StartNew<TResult>(
    Func<TResult> function,
    CancellationToken cancellationToken
)

Parameters

function
Type: System..::.Func<(Of <(TResult>)>)
A function delegate that returns the future result to be available through the Task<(Of <(TResult>)>).
cancellationToken
Type: System.Threading..::.CancellationToken
The CancellationToken that will be assigned to the new Task

Type Parameters

TResult
The type of the result available through the Task.

Return Value

The started Task<(Of <(TResult>)>).

Remarks

Calling StartNew is functionally equivalent to creating a Task<(Of <(TResult>)>) using one of its constructors and then calling Start to schedule it for execution. However, unless creation and scheduling must be separated, StartNew is the recommended approach for both simplicity and performance.

Exceptions

Exception | Condition
System..::.ArgumentNullException | The exception that is thrown when the function argument is null.
System..::.ObjectDisposedException | The provided CancellationToken has already been disposed.

See Also

TaskFactory Class
StartNew Overload
System.Threading.Tasks Namespace


StartNew(TResult) Method (Func(TResult), TaskCreationOptions)

[image]

.NET Framework Class Library
TaskFactory..::.StartNew<(Of <(TResult>)>) Method (Func<(Of <(TResult>)>), TaskCreationOptions)
TaskFactory Class See Also Send Feedback

Creates and starts a Task<(Of <(TResult>)>).

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Function StartNew(Of TResult) ( _
    function As Func(Of TResult), _
    creationOptions As TaskCreationOptions _
) As Task(Of TResult)
C#
public Task<TResult> StartNew<TResult>(
    Func<TResult> function,
    TaskCreationOptions creationOptions
)

Parameters

function
Type: System..::.Func<(Of <(TResult>)>)
A function delegate that returns the future result to be available through the Task<(Of <(TResult>)>).
creationOptions
Type: System.Threading.Tasks..::.TaskCreationOptions
A TaskCreationOptions value that controls the behavior of the created Task<(Of <(TResult>)>).

Type Parameters

TResult
The type of the result available through the Task.

Return Value

The started Task<(Of <(TResult>)>).

Remarks

Calling StartNew is functionally equivalent to creating a Task<(Of <(TResult>)>) using one of its constructors and then calling Start to schedule it for execution. However, unless creation and scheduling must be separated, StartNew is the recommended approach for both simplicity and performance.

Exceptions

Exception | Condition
System..::.ArgumentNullException | The exception that is thrown when the function argument is null.
System..::.ArgumentOutOfRangeException | The exception that is thrown when the creationOptions argument specifies an invalid TaskCreationOptions value.

See Also

TaskFactory Class
StartNew Overload
System.Threading.Tasks Namespace


StartNew(TResult) Method (Func(Object, TResult), Object)

[image]

.NET Framework Class Library
TaskFactory..::.StartNew<(Of <(TResult>)>) Method (Func<(Of <(Object, TResult>)>), Object)
TaskFactory Class See Also Send Feedback

Creates and starts a Task<(Of <(TResult>)>).

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Function StartNew(Of TResult) ( _
    function As Func(Of Object, TResult), _
    state As Object _
) As Task(Of TResult)
C#
public Task<TResult> StartNew<TResult>(
    Func<Object, TResult> function,
    Object state
)

Parameters

function
Type: System..::.Func<(Of <(Object, TResult>)>)
A function delegate that returns the future result to be available through the Task<(Of <(TResult>)>).
state
Type: System..::.Object
An object containing data to be used by the function delegate.

Type Parameters

TResult
The type of the result available through the Task.

Return Value

The started Task<(Of <(TResult>)>).

Remarks

Calling StartNew is functionally equivalent to creating a Task<(Of <(TResult>)>) using one of its constructors and then calling Start to schedule it for execution. However, unless creation and scheduling must be separated, StartNew is the recommended approach for both simplicity and performance.

Exceptions

Exception | Condition
System..::.ArgumentNullException | The exception that is thrown when the function argument is null.

See Also

TaskFactory Class
StartNew Overload
System.Threading.Tasks Namespace


StartNew Method (Action(Object), Object, CancellationToken)

[image]

.NET Framework Class Library
TaskFactory..::.StartNew Method (Action<(Of <(Object>)>), Object, CancellationToken)
TaskFactory Class See Also Send Feedback

Creates and starts a Task.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Function StartNew ( _
    action As Action(Of Object), _
    state As Object, _
    cancellationToken As CancellationToken _
) As Task
C#
public Task StartNew(
    Action<Object> action,
    Object state,
    CancellationToken cancellationToken
)

Parameters

action
Type: System..::.Action<(Of <(Object>)>)
The action delegate to execute asynchronously.
state
Type: System..::.Object
An object containing data to be used by the action delegate.
cancellationToken
Type: System.Threading..::.CancellationToken
The CancellationToken that will be assigned to the new Task

Return Value

The started Task.

Remarks

Calling StartNew is functionally equivalent to creating a Task using one of its constructors and then calling Start to schedule it for execution. However, unless creation and scheduling must be separated, StartNew is the recommended approach for both simplicity and performance.

Exceptions

Exception | Condition
System..::.ArgumentNullException | The exception that is thrown when the action argument is null.
System..::.ObjectDisposedException | The provided CancellationToken has already been disposed.

See Also

TaskFactory Class
StartNew Overload
System.Threading.Tasks Namespace


StartNew Method (Action(Object), Object, TaskCreationOptions)

[image]

.NET Framework Class Library
TaskFactory..::.StartNew Method (Action<(Of <(Object>)>), Object, TaskCreationOptions)
TaskFactory Class See Also Send Feedback

Creates and starts a Task.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Function StartNew ( _
    action As Action(Of Object), _
    state As Object, _
    creationOptions As TaskCreationOptions _
) As Task
C#
public Task StartNew(
    Action<Object> action,
    Object state,
    TaskCreationOptions creationOptions
)

Parameters

action
Type: System..::.Action<(Of <(Object>)>)
The action delegate to execute asynchronously.
state
Type: System..::.Object
An object containing data to be used by the action delegate.
creationOptions
Type: System.Threading.Tasks..::.TaskCreationOptions
A TaskCreationOptions value that controls the behavior of the created Task.

Return Value

The started Task.

Remarks

Calling StartNew is functionally equivalent to creating a Task using one of its constructors and then calling Start to schedule it for execution. However, unless creation and scheduling must be separated, StartNew is the recommended approach for both simplicity and performance.

Exceptions

Exception | Condition
System..::.ArgumentNullException | The exception that is thrown when the action argument is null.
System..::.ArgumentOutOfRangeException | The exception that is thrown when the creationOptions argument specifies an invalid TaskCreationOptions value.

See Also

TaskFactory Class
StartNew Overload
System.Threading.Tasks Namespace


StartNew(TResult) Method (Func(Object, TResult), Object, CancellationToken)

[image]

.NET Framework Class Library
TaskFactory..::.StartNew<(Of <(TResult>)>) Method (Func<(Of <(Object, TResult>)>), Object, CancellationToken)
TaskFactory Class See Also Send Feedback

Creates and starts a Task<(Of <(TResult>)>).

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Function StartNew(Of TResult) ( _
    function As Func(Of Object, TResult), _
    state As Object, _
    cancellationToken As CancellationToken _
) As Task(Of TResult)
C#
public Task<TResult> StartNew<TResult>(
    Func<Object, TResult> function,
    Object state,
    CancellationToken cancellationToken
)

Parameters

function
Type: System..::.Func<(Of <(Object, TResult>)>)
A function delegate that returns the future result to be available through the Task<(Of <(TResult>)>).
state
Type: System..::.Object
An object containing data to be used by the function delegate.
cancellationToken
Type: System.Threading..::.CancellationToken
The CancellationToken that will be assigned to the new Task

Type Parameters

TResult
The type of the result available through the Task.

Return Value

The started Task<(Of <(TResult>)>).

Remarks

Calling StartNew is functionally equivalent to creating a Task<(Of <(TResult>)>) using one of its constructors and then calling Start to schedule it for execution. However, unless creation and scheduling must be separated, StartNew is the recommended approach for both simplicity and performance.

Exceptions

Exception | Condition
System..::.ArgumentNullException | The exception that is thrown when the function argument is null.
System..::.ObjectDisposedException | The provided CancellationToken has already been disposed.

See Also

TaskFactory Class
StartNew Overload
System.Threading.Tasks Namespace


StartNew(TResult) Method (Func(Object, TResult), Object, TaskCreationOptions)

[image]

.NET Framework Class Library
TaskFactory..::.StartNew<(Of <(TResult>)>) Method (Func<(Of <(Object, TResult>)>), Object, TaskCreationOptions)
TaskFactory Class See Also Send Feedback

Creates and starts a Task<(Of <(TResult>)>).

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Function StartNew(Of TResult) ( _
    function As Func(Of Object, TResult), _
    state As Object, _
    creationOptions As TaskCreationOptions _
) As Task(Of TResult)
C#
public Task<TResult> StartNew<TResult>(
    Func<Object, TResult> function,
    Object state,
    TaskCreationOptions creationOptions
)

Parameters

function
Type: System..::.Func<(Of <(Object, TResult>)>)
A function delegate that returns the future result to be available through the Task<(Of <(TResult>)>).
state
Type: System..::.Object
An object containing data to be used by the function delegate.
creationOptions
Type: System.Threading.Tasks..::.TaskCreationOptions
A TaskCreationOptions value that controls the behavior of the created Task<(Of <(TResult>)>).

Type Parameters

TResult
The type of the result available through the Task.

Return Value

The started Task<(Of <(TResult>)>).

Remarks

Calling StartNew is functionally equivalent to creating a Task<(Of <(TResult>)>) using one of its constructors and then calling Start to schedule it for execution. However, unless creation and scheduling must be separated, StartNew is the recommended approach for both simplicity and performance.

Exceptions

Exception | Condition
System..::.ArgumentNullException | The exception that is thrown when the function argument is null.
System..::.ArgumentOutOfRangeException | The exception that is thrown when the creationOptions argument specifies an invalid TaskCreationOptions value.

See Also

TaskFactory Class
StartNew Overload
System.Threading.Tasks Namespace


StartNew Method (Action, CancellationToken, TaskCreationOptions, TaskScheduler)

[image]

.NET Framework Class Library
TaskFactory..::.StartNew Method (Action, CancellationToken, TaskCreationOptions, TaskScheduler)
TaskFactory Class See Also Send Feedback

Creates and starts a Task.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Function StartNew ( _
    action As Action, _
    cancellationToken As CancellationToken, _
    creationOptions As TaskCreationOptions, _
    scheduler As TaskScheduler _
) As Task
C#
public Task StartNew(
    Action action,
    CancellationToken cancellationToken,
    TaskCreationOptions creationOptions,
    TaskScheduler scheduler
)

Parameters

action
Type: System..::.Action
The action delegate to execute asynchronously.
cancellationToken
Type: System.Threading..::.CancellationToken
The CancellationToken that will be assigned to the new Task
creationOptions
Type: System.Threading.Tasks..::.TaskCreationOptions
A TaskCreationOptions value that controls the behavior of the created Task.
scheduler
Type: System.Threading.Tasks..::.TaskScheduler
The TaskScheduler that is used to schedule the created Task.

Return Value

The started Task.

Remarks

Calling StartNew is functionally equivalent to creating a Task using one of its constructors and then calling Start to schedule it for execution. However, unless creation and scheduling must be separated, StartNew is the recommended approach for both simplicity and performance.

Exceptions

Exception | Condition
System..::.ArgumentNullException | The exception that is thrown when the action argument is null.
System..::.ArgumentNullException | The exception that is thrown when the scheduler argument is null.
System..::.ArgumentOutOfRangeException | The exception that is thrown when the creationOptions argument specifies an invalid TaskCreationOptions value.
System..::.ObjectDisposedException | The provided CancellationToken has already been disposed.

See Also

TaskFactory Class
StartNew Overload
System.Threading.Tasks Namespace


StartNew(TResult) Method (Func(TResult), CancellationToken, TaskCreationOptions, TaskScheduler)

[image]

.NET Framework Class Library
TaskFactory..::.StartNew<(Of <(TResult>)>) Method (Func<(Of <(TResult>)>), CancellationToken, TaskCreationOptions, TaskScheduler)
TaskFactory Class See Also Send Feedback

Creates and starts a Task<(Of <(TResult>)>).

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Function StartNew(Of TResult) ( _
    function As Func(Of TResult), _
    cancellationToken As CancellationToken, _
    creationOptions As TaskCreationOptions, _
    scheduler As TaskScheduler _
) As Task(Of TResult)
C#
public Task<TResult> StartNew<TResult>(
    Func<TResult> function,
    CancellationToken cancellationToken,
    TaskCreationOptions creationOptions,
    TaskScheduler scheduler
)

Parameters

function
Type: System..::.Func<(Of <(TResult>)>)
A function delegate that returns the future result to be available through the Task<(Of <(TResult>)>).
cancellationToken
Type: System.Threading..::.CancellationToken
The CancellationToken that will be assigned to the new task.
creationOptions
Type: System.Threading.Tasks..::.TaskCreationOptions
A TaskCreationOptions value that controls the behavior of the created Task<(Of <(TResult>)>).
scheduler
Type: System.Threading.Tasks..::.TaskScheduler
The TaskScheduler that is used to schedule the created Task{TResult}.

Type Parameters

TResult
The type of the result available through the Task.

Return Value

The started Task<(Of <(TResult>)>).

Remarks

Calling StartNew is functionally equivalent to creating a Task<(Of <(TResult>)>) using one of its constructors and then calling Start to schedule it for execution. However, unless creation and scheduling must be separated, StartNew is the recommended approach for both simplicity and performance.

Exceptions

Exception | Condition
System..::.ArgumentNullException | The exception that is thrown when the function argument is null.
System..::.ArgumentNullException | The exception that is thrown when the scheduler argument is null.
System..::.ArgumentOutOfRangeException | The exception that is thrown when the creationOptions argument specifies an invalid TaskCreationOptions value.
System..::.ObjectDisposedException | The provided CancellationToken has already been disposed.

See Also

TaskFactory Class
StartNew Overload
System.Threading.Tasks Namespace


StartNew Method (Action(Object), Object, CancellationToken, TaskCreationOptions, TaskScheduler)

[image]

.NET Framework Class Library
TaskFactory..::.StartNew Method (Action<(Of <(Object>)>), Object, CancellationToken, TaskCreationOptions, TaskScheduler)
TaskFactory Class See Also Send Feedback

Creates and starts a Task.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Function StartNew ( _
    action As Action(Of Object), _
    state As Object, _
    cancellationToken As CancellationToken, _
    creationOptions As TaskCreationOptions, _
    scheduler As TaskScheduler _
) As Task
C#
public Task StartNew(
    Action<Object> action,
    Object state,
    CancellationToken cancellationToken,
    TaskCreationOptions creationOptions,
    TaskScheduler scheduler
)

Parameters

action
Type: System..::.Action<(Of <(Object>)>)
The action delegate to execute asynchronously.
state
Type: System..::.Object
An object containing data to be used by the action delegate.
cancellationToken
Type: System.Threading..::.CancellationToken
The CancellationToken that will be assigned to the new task.
creationOptions
Type: System.Threading.Tasks..::.TaskCreationOptions
A TaskCreationOptions value that controls the behavior of the created Task.
scheduler
Type: System.Threading.Tasks..::.TaskScheduler
The TaskScheduler that is used to schedule the created Task.

Return Value

The started Task.

Remarks

Calling StartNew is functionally equivalent to creating a Task using one of its constructors and then calling Start to schedule it for execution. However, unless creation and scheduling must be separated, StartNew is the recommended approach for both simplicity and performance.

Exceptions

Exception | Condition
System..::.ArgumentNullException | The exception that is thrown when the action argument is null.
System..::.ArgumentNullException | The exception that is thrown when the scheduler argument is null.
System..::.ArgumentOutOfRangeException | The exception that is thrown when the creationOptions argument specifies an invalid TaskCreationOptions value.
System..::.ObjectDisposedException | The provided CancellationToken has already been disposed.

See Also

TaskFactory Class
StartNew Overload
System.Threading.Tasks Namespace


StartNew(TResult) Method (Func(Object, TResult), Object, CancellationToken, TaskCreationOptions, TaskScheduler)

[image]

.NET Framework Class Library
TaskFactory..::.StartNew<(Of <(TResult>)>) Method (Func<(Of <(Object, TResult>)>), Object, CancellationToken, TaskCreationOptions, TaskScheduler)
TaskFactory Class See Also Send Feedback

Creates and starts a Task<(Of <(TResult>)>).

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Function StartNew(Of TResult) ( _
    function As Func(Of Object, TResult), _
    state As Object, _
    cancellationToken As CancellationToken, _
    creationOptions As TaskCreationOptions, _
    scheduler As TaskScheduler _
) As Task(Of TResult)
C#
public Task<TResult> StartNew<TResult>(
    Func<Object, TResult> function,
    Object state,
    CancellationToken cancellationToken,
    TaskCreationOptions creationOptions,
    TaskScheduler scheduler
)

Parameters

function
Type: System..::.Func<(Of <(Object, TResult>)>)
A function delegate that returns the future result to be available through the Task<(Of <(TResult>)>).
state
Type: System..::.Object
An object containing data to be used by the function delegate.
cancellationToken
Type: System.Threading..::.CancellationToken
The CancellationToken that will be assigned to the new task.
creationOptions
Type: System.Threading.Tasks..::.TaskCreationOptions
A TaskCreationOptions value that controls the behavior of the created Task<(Of <(TResult>)>).
scheduler
Type: System.Threading.Tasks..::.TaskScheduler
The TaskScheduler that is used to schedule the created Task{TResult}.

Type Parameters

TResult
The type of the result available through the Task.

Return Value

The started Task<(Of <(TResult>)>).

Remarks

Calling StartNew is functionally equivalent to creating a Task<(Of <(TResult>)>) using one of its constructors and then calling Start to schedule it for execution. However, unless creation and scheduling must be separated, StartNew is the recommended approach for both simplicity and performance.

Exceptions

Exception | Condition
System..::.ArgumentNullException | The exception that is thrown when the function argument is null.
System..::.ArgumentNullException | The exception that is thrown when the scheduler argument is null.
System..::.ArgumentOutOfRangeException | The exception that is thrown when the creationOptions argument specifies an invalid TaskCreationOptions value.
System..::.ObjectDisposedException | The provided CancellationToken has already been disposed.

See Also

TaskFactory Class
StartNew Overload
System.Threading.Tasks Namespace


TaskFactory Properties

[image] [image]

.NET Framework Class Library
TaskFactory Properties
TaskFactory Class See Also Send Feedback

The TaskFactory type exposes the following members.

Properties

Name | Description
CancellationToken | Gets the default CancellationToken of this TaskFactory.
ContinuationOptions | Gets the TaskContinuationOptions value of this TaskFactory.
CreationOptions | Gets the TaskCreationOptions value of this TaskFactory.
Scheduler | Gets the TaskScheduler of this TaskFactory.

See Also

TaskFactory Class
System.Threading.Tasks Namespace


CancellationToken Property

[image]

.NET Framework Class Library
TaskFactory..::.CancellationToken Property
TaskFactory Class See Also Send Feedback

Gets the default CancellationToken of this TaskFactory.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public ReadOnly Property CancellationToken As CancellationToken
C#
public CancellationToken CancellationToken { get; }

Remarks

This property returns the default CancellationToken that will be assigned to all tasks created by this factory unless another CancellationToken value is explicitly specified during the call to the factory methods.

See Also

TaskFactory Class
System.Threading.Tasks Namespace


ContinuationOptions Property

[image]

.NET Framework Class Library
TaskFactory..::.ContinuationOptions Property
TaskFactory Class See Also Send Feedback

Gets the TaskContinuationOptions value of this TaskFactory.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public ReadOnly Property ContinuationOptions As TaskContinuationOptions
C#
public TaskContinuationOptions ContinuationOptions { get; }

Remarks

This property returns the default continuation options for this factory. They will be used to create all continuation tasks unless other options are explicitly specified during calls to this factory's methods.

See Also

TaskFactory Class
System.Threading.Tasks Namespace


CreationOptions Property

[image]

.NET Framework Class Library
TaskFactory..::.CreationOptions Property
TaskFactory Class See Also Send Feedback

Gets the TaskCreationOptions value of this TaskFactory.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public ReadOnly Property CreationOptions As TaskCreationOptions
C#
public TaskCreationOptions CreationOptions { get; }

Remarks

This property returns the default creation options for this factory. They will be used to create all tasks unless other options are explicitly specified during calls to this factory's methods.

See Also

TaskFactory Class
System.Threading.Tasks Namespace


Scheduler Property

[image]

.NET Framework Class Library
TaskFactory..::.Scheduler Property
TaskFactory Class See Also Send Feedback

Gets the TaskScheduler of this TaskFactory.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public ReadOnly Property Scheduler As TaskScheduler
C#
public TaskScheduler Scheduler { get; }

Remarks

This property returns the default scheduler for this factory. It will be used to schedule all tasks unless another scheduler is explicitly specified during calls to this factory's methods. If null, TaskScheduler.Current will be used.

See Also

TaskFactory Class
System.Threading.Tasks Namespace


TaskFactory(TResult) Class

[image]

.NET Framework Class Library
TaskFactory<(Of <(TResult>)>) Class
See Also Send Feedback

Provides support for creating and scheduling Task{TResult} objects.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
<HostProtectionAttribute(SecurityAction.LinkDemand, Synchronization := True,  _
    ExternalThreading := True)> _
Public Class TaskFactory(Of TResult)
C#
[HostProtectionAttribute(SecurityAction.LinkDemand, Synchronization = true,
    ExternalThreading = true)]
public class TaskFactory<TResult>

Type Parameters

TResult
The type of the results that are available though the Task{TResult} objects that are associated with the methods in this class.

Remarks

There are many common patterns for which tasks are relevant. The TaskFactory<(Of <(TResult>)>) class encodes some of these patterns into methods that pick up default settings, which are configurable through its constructors.

A default instance of TaskFactory<(Of <(TResult>)>) is available through the Task{TResult}.Factory property.

Inheritance Hierarchy

System..::.Object
System.Threading.Tasks..::.TaskFactory<(Of <(TResult>)>)

See Also

System.Threading.Tasks Namespace


TaskFactory(TResult) Constructor

[image] [image]

.NET Framework Class Library
TaskFactory<(Of <(TResult>)>) Constructor
TaskFactory<(Of <(TResult>)>) Class See Also Send Feedback

Overload List

Name | Description
TaskFactory<(Of <(TResult>)>)()()() | Initializes a TaskFactory<(Of <(TResult>)>) instance with the default configuration.
TaskFactory<(Of <(TResult>)>)(CancellationToken) | Initializes a TaskFactory<(Of <(TResult>)>) instance with the default configuration.
TaskFactory<(Of <(TResult>)>)(TaskScheduler) | Initializes a TaskFactory<(Of <(TResult>)>) instance with the specified configuration.
TaskFactory<(Of <(TResult>)>)(TaskCreationOptions, TaskContinuationOptions) | Initializes a TaskFactory<(Of <(TResult>)>) instance with the specified configuration.
TaskFactory<(Of <(TResult>)>)(CancellationToken, TaskCreationOptions, TaskContinuationOptions, TaskScheduler) | Initializes a TaskFactory<(Of <(TResult>)>) instance with the specified configuration.

See Also

TaskFactory<(Of <(TResult>)>) Class
System.Threading.Tasks Namespace


TaskFactory(TResult) Constructor

[image]

.NET Framework Class Library
TaskFactory<(Of <(TResult>)>) Constructor
TaskFactory<(Of <(TResult>)>) Class See Also Send Feedback

Initializes a TaskFactory<(Of <(TResult>)>) instance with the default configuration.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Sub New
C#
public TaskFactory()

Remarks

This constructor creates a TaskFactory<(Of <(TResult>)>) instance with a default configuration. The TaskCreationOptions property is initialized to TaskCreationOptions.None, the TaskContinuationOptions property is initialized to TaskContinuationOptions.None, and the TaskScheduler property is initialized to the current scheduler (see TaskScheduler.Current).

See Also

TaskFactory<(Of <(TResult>)>) Class
TaskFactory<(Of <(TResult>)>) Overload
System.Threading.Tasks Namespace


TaskFactory(TResult) Constructor (CancellationToken)

[image]

.NET Framework Class Library
TaskFactory<(Of <(TResult>)>) Constructor (CancellationToken)
TaskFactory<(Of <(TResult>)>) Class See Also Send Feedback

Initializes a TaskFactory<(Of <(TResult>)>) instance with the default configuration.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Sub New ( _
    cancellationToken As CancellationToken _
)
C#
public TaskFactory(
    CancellationToken cancellationToken
)

Parameters

cancellationToken
Type: System.Threading..::.CancellationToken
The default CancellationToken that will be assigned to tasks created by this TaskFactory unless another CancellationToken is explicitly specified while calling the factory methods.

Remarks

This constructor creates a TaskFactory<(Of <(TResult>)>) instance with a default configuration. The TaskCreationOptions property is initialized to TaskCreationOptions.None, the TaskContinuationOptions property is initialized to TaskContinuationOptions.None, and the TaskScheduler property is initialized to the current scheduler (see TaskScheduler.Current).

See Also

TaskFactory<(Of <(TResult>)>) Class
TaskFactory<(Of <(TResult>)>) Overload
System.Threading.Tasks Namespace


TaskFactory(TResult) Constructor (TaskScheduler)

[image]

.NET Framework Class Library
TaskFactory<(Of <(TResult>)>) Constructor (TaskScheduler)
TaskFactory<(Of <(TResult>)>) Class See Also Send Feedback

Initializes a TaskFactory<(Of <(TResult>)>) instance with the specified configuration.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Sub New ( _
    scheduler As TaskScheduler _
)
C#
public TaskFactory(
    TaskScheduler scheduler
)

Parameters

scheduler
Type: System.Threading.Tasks..::.TaskScheduler
The TaskScheduler to use to schedule any tasks created with this TaskFactory{TResult}. A null value indicates that the current TaskScheduler should be used.

Remarks

With this constructor, the TaskCreationOptions property is initialized to TaskCreationOptions.None, the TaskContinuationOptions property is initialized to TaskContinuationOptions.None, and the TaskScheduler property is initialized to scheduler, unless it's null, in which case the property is initialized to the current scheduler (see TaskScheduler.Current).

See Also

TaskFactory<(Of <(TResult>)>) Class
TaskFactory<(Of <(TResult>)>) Overload
System.Threading.Tasks Namespace


TaskFactory(TResult) Constructor (TaskCreationOptions, TaskContinuationOptions)

[image]

.NET Framework Class Library
TaskFactory<(Of <(TResult>)>) Constructor (TaskCreationOptions, TaskContinuationOptions)
TaskFactory<(Of <(TResult>)>) Class See Also Send Feedback

Initializes a TaskFactory<(Of <(TResult>)>) instance with the specified configuration.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Sub New ( _
    creationOptions As TaskCreationOptions, _
    continuationOptions As TaskContinuationOptions _
)
C#
public TaskFactory(
    TaskCreationOptions creationOptions,
    TaskContinuationOptions continuationOptions
)

Parameters

creationOptions
Type: System.Threading.Tasks..::.TaskCreationOptions
The default TaskCreationOptions to use when creating tasks with this TaskFactory{TResult}.
continuationOptions
Type: System.Threading.Tasks..::.TaskContinuationOptions
The default TaskContinuationOptions to use when creating continuation tasks with this TaskFactory{TResult}.

Remarks

With this constructor, the TaskCreationOptions property is initialized to creationOptions, the TaskContinuationOptions property is initialized to continuationOptions, and the TaskScheduler property is initialized to the current scheduler (see TaskScheduler.Current).

Exceptions

Exception | Condition
System..::.ArgumentOutOfRangeException | The exception that is thrown when the creationOptions argument or the continuationOptions argument specifies an invalid value.

See Also

TaskFactory<(Of <(TResult>)>) Class
TaskFactory<(Of <(TResult>)>) Overload
System.Threading.Tasks Namespace


TaskFactory(TResult) Constructor (CancellationToken, TaskCreationOptions, TaskContinuationOptions, TaskScheduler)

[image]

.NET Framework Class Library
TaskFactory<(Of <(TResult>)>) Constructor (CancellationToken, TaskCreationOptions, TaskContinuationOptions, TaskScheduler)
TaskFactory<(Of <(TResult>)>) Class See Also Send Feedback

Initializes a TaskFactory<(Of <(TResult>)>) instance with the specified configuration.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Sub New ( _
    cancellationToken As CancellationToken, _
    creationOptions As TaskCreationOptions, _
    continuationOptions As TaskContinuationOptions, _
    scheduler As TaskScheduler _
)
C#
public TaskFactory(
    CancellationToken cancellationToken,
    TaskCreationOptions creationOptions,
    TaskContinuationOptions continuationOptions,
    TaskScheduler scheduler
)

Parameters

cancellationToken
Type: System.Threading..::.CancellationToken
The default CancellationToken that will be assigned to tasks created by this TaskFactory unless another CancellationToken is explicitly specified while calling the factory methods.
creationOptions
Type: System.Threading.Tasks..::.TaskCreationOptions
The default TaskCreationOptions to use when creating tasks with this TaskFactory{TResult}.
continuationOptions
Type: System.Threading.Tasks..::.TaskContinuationOptions
The default TaskContinuationOptions to use when creating continuation tasks with this TaskFactory{TResult}.
scheduler
Type: System.Threading.Tasks..::.TaskScheduler
The default TaskScheduler to use to schedule any Tasks created with this TaskFactory{TResult}. A null value indicates that TaskScheduler.Current should be used.

Remarks

With this constructor, the TaskCreationOptions property is initialized to creationOptions, the TaskContinuationOptions property is initialized to continuationOptions, and the TaskScheduler property is initialized to scheduler, unless it's null, in which case the property is initialized to the current scheduler (see TaskScheduler.Current).

Exceptions

Exception | Condition
System..::.ArgumentOutOfRangeException | The exception that is thrown when the creationOptions argument or the continuationOptions argumentspecifies an invalid value.

See Also

TaskFactory<(Of <(TResult>)>) Class
TaskFactory<(Of <(TResult>)>) Overload
System.Threading.Tasks Namespace


TaskFactory(TResult) Methods

[image] [image]

.NET Framework Class Library
TaskFactory<(Of <(TResult>)>) Methods
TaskFactory<(Of <(TResult>)>) Class See Also Send Feedback

The TaskFactory<(Of <(TResult>)>) type exposes the following members.

Methods

Name | Description
ContinueWhenAll | Overloaded.
ContinueWhenAny | Overloaded.
Equals | (Inherited from Object.)
Finalize | (Inherited from Object.)
FromAsync | Overloaded.
GetHashCode | (Inherited from Object.)
GetType | (Inherited from Object.)
MemberwiseClone | (Inherited from Object.)
StartNew | Overloaded.
ToString | (Inherited from Object.)

See Also

TaskFactory<(Of <(TResult>)>) Class
System.Threading.Tasks Namespace


ContinueWhenAll Method

[image] [image]

.NET Framework Class Library
TaskFactory<(Of <(TResult>)>)..::.ContinueWhenAll Method
TaskFactory<(Of <(TResult>)>) Class See Also Send Feedback

Overload List

Name | Description
ContinueWhenAll(array<Task>[]()[], Func<(Of <(array<Task>[]()[], TResult>)>)) | Creates a continuation Task that will be started upon the completion of a set of provided Tasks.
ContinueWhenAll<(Of <(TAntecedentResult>)>)(array<Task<(Of <(TAntecedentResult>)>)>[]()[], Func<(Of <(array<Task<(Of <(TAntecedentResult>)>)>[]()[], TResult>)>)) | Creates a continuation Task that will be started upon the completion of a set of provided Tasks.
ContinueWhenAll(array<Task>[]()[], Func<(Of <(array<Task>[]()[], TResult>)>), CancellationToken) | Creates a continuation Task that will be started upon the completion of a set of provided Tasks.
ContinueWhenAll(array<Task>[]()[], Func<(Of <(array<Task>[]()[], TResult>)>), TaskContinuationOptions) | Creates a continuation Task that will be started upon the completion of a set of provided Tasks.
ContinueWhenAll<(Of <(TAntecedentResult>)>)(array<Task<(Of <(TAntecedentResult>)>)>[]()[], Func<(Of <(array<Task<(Of <(TAntecedentResult>)>)>[]()[], TResult>)>), CancellationToken) | Creates a continuation Task that will be started upon the completion of a set of provided Tasks.
ContinueWhenAll<(Of <(TAntecedentResult>)>)(array<Task<(Of <(TAntecedentResult>)>)>[]()[], Func<(Of <(array<Task<(Of <(TAntecedentResult>)>)>[]()[], TResult>)>), TaskContinuationOptions) | Creates a continuation Task that will be started upon the completion of a set of provided Tasks.
ContinueWhenAll(array<Task>[]()[], Func<(Of <(array<Task>[]()[], TResult>)>), CancellationToken, TaskContinuationOptions, TaskScheduler) | Creates a continuation Task that will be started upon the completion of a set of provided Tasks.
ContinueWhenAll<(Of <(TAntecedentResult>)>)(array<Task<(Of <(TAntecedentResult>)>)>[]()[], Func<(Of <(array<Task<(Of <(TAntecedentResult>)>)>[]()[], TResult>)>), CancellationToken, TaskContinuationOptions, TaskScheduler) | Creates a continuation Task that will be started upon the completion of a set of provided Tasks.

See Also

TaskFactory<(Of <(TResult>)>) Class
System.Threading.Tasks Namespace


ContinueWhenAll Method (Task[], Func(Task[], TResult))

[image]

.NET Framework Class Library
TaskFactory<(Of <(TResult>)>)..::.ContinueWhenAll Method (array<Task>[]()[], Func<(Of <(array<Task>[]()[], TResult>)>))
TaskFactory<(Of <(TResult>)>) Class See Also Send Feedback

Creates a continuation Task that will be started upon the completion of a set of provided Tasks.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Function ContinueWhenAll ( _
    tasks As Task(), _
    continuationFunction As Func(Of Task(), TResult) _
) As Task(Of TResult)
C#
public Task<TResult> ContinueWhenAll(
    Task[] tasks,
    Func<Task[], TResult> continuationFunction
)

Parameters

tasks
Type: array< System.Threading.Tasks..::.Task >[]()[]
The array of tasks from which to continue.
continuationFunction
Type: System..::.Func<(Of <(array< Task >[]()[], TResult >)>)
The function delegate to execute when all tasks in the tasks array have completed.

Return Value

The new continuation Task.

Exceptions

Exception | Condition
System..::.ArgumentNullException | The exception that is thrown when the tasks array is null.
System..::.ArgumentNullException | The exception that is thrown when the continuationFunction argument is null.
System..::.ArgumentException | The exception that is thrown when the tasks array contains a null value.
System..::.ArgumentException | The exception that is thrown when the tasks array is empty.
System..::.ObjectDisposedException | The exception that is thrown when one of the elements in the tasks array has been disposed.

See Also

TaskFactory<(Of <(TResult>)>) Class
ContinueWhenAll Overload
System.Threading.Tasks Namespace


ContinueWhenAll(TAntecedentResult) Method (Task(TAntecedentResult)[], Func(Task(TAntecedentResult)[], TResult))

[image]

.NET Framework Class Library
TaskFactory<(Of <(TResult>)>)..::.ContinueWhenAll<(Of <(TAntecedentResult>)>) Method (array<Task<(Of <(TAntecedentResult>)>)>[]()[], Func<(Of <(array<Task<(Of <(TAntecedentResult>)>)>[]()[], TResult>)>))
TaskFactory<(Of <(TResult>)>) Class See Also Send Feedback

Creates a continuation Task that will be started upon the completion of a set of provided Tasks.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Function ContinueWhenAll(Of TAntecedentResult) ( _
    tasks As Task(Of TAntecedentResult)(), _
    continuationFunction As Func(Of Task(Of TAntecedentResult)(), TResult) _
) As Task(Of TResult)
C#
public Task<TResult> ContinueWhenAll<TAntecedentResult>(
    Task<TAntecedentResult>[] tasks,
    Func<Task<TAntecedentResult>[], TResult> continuationFunction
)

Parameters

tasks
Type: array< System.Threading.Tasks..::.Task <(Of <(TAntecedentResult>)>) >[]()[]
The array of tasks from which to continue.
continuationFunction
Type: System..::.Func<(Of <(array< Task <(Of <(TAntecedentResult>)>) >[]()[], TResult >)>)
The function delegate to execute when all tasks in the tasks array have completed.

Type Parameters

TAntecedentResult
The type of the result of the antecedent tasks.

Return Value

The new continuation Task<(Of <(TResult>)>).

Exceptions

Exception | Condition
System..::.ArgumentNullException | The exception that is thrown when the tasks array is null.
System..::.ArgumentNullException | The exception that is thrown when the continuationFunction argument is null.
System..::.ArgumentException | The exception that is thrown when the tasks array contains a null value.
System..::.ArgumentException | The exception that is thrown when the tasks array is empty.
System..::.ObjectDisposedException | The exception that is thrown when one of the elements in the tasks array has been disposed.

See Also

TaskFactory<(Of <(TResult>)>) Class
ContinueWhenAll Overload
System.Threading.Tasks Namespace


ContinueWhenAll Method (Task[], Func(Task[], TResult), CancellationToken)

[image]

.NET Framework Class Library
TaskFactory<(Of <(TResult>)>)..::.ContinueWhenAll Method (array<Task>[]()[], Func<(Of <(array<Task>[]()[], TResult>)>), CancellationToken)
TaskFactory<(Of <(TResult>)>) Class See Also Send Feedback

Creates a continuation Task that will be started upon the completion of a set of provided Tasks.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Function ContinueWhenAll ( _
    tasks As Task(), _
    continuationFunction As Func(Of Task(), TResult), _
    cancellationToken As CancellationToken _
) As Task(Of TResult)
C#
public Task<TResult> ContinueWhenAll(
    Task[] tasks,
    Func<Task[], TResult> continuationFunction,
    CancellationToken cancellationToken
)

Parameters

tasks
Type: array< System.Threading.Tasks..::.Task >[]()[]
The array of tasks from which to continue.
continuationFunction
Type: System..::.Func<(Of <(array< Task >[]()[], TResult >)>)
The function delegate to execute when all tasks in the tasks array have completed.
cancellationToken
Type: System.Threading..::.CancellationToken
The CancellationToken that will be assigned to the new continuation task.

Return Value

The new continuation Task.

Exceptions

Exception | Condition
System..::.ArgumentNullException | The exception that is thrown when the tasks array is null.
System..::.ArgumentNullException | The exception that is thrown when the continuationFunction argument is null.
System..::.ArgumentException | The exception that is thrown when the tasks array contains a null value.
System..::.ArgumentException | The exception that is thrown when the tasks array is empty.
System..::.ObjectDisposedException | The exception that is thrown when one of the elements in the tasks array has been disposed.
System..::.ObjectDisposedException | The provided CancellationToken has already been disposed.

See Also

TaskFactory<(Of <(TResult>)>) Class
ContinueWhenAll Overload
System.Threading.Tasks Namespace


ContinueWhenAll Method (Task[], Func(Task[], TResult), TaskContinuationOptions)

[image]

.NET Framework Class Library
TaskFactory<(Of <(TResult>)>)..::.ContinueWhenAll Method (array<Task>[]()[], Func<(Of <(array<Task>[]()[], TResult>)>), TaskContinuationOptions)
TaskFactory<(Of <(TResult>)>) Class See Also Send Feedback

Creates a continuation Task that will be started upon the completion of a set of provided Tasks.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Function ContinueWhenAll ( _
    tasks As Task(), _
    continuationFunction As Func(Of Task(), TResult), _
    continuationOptions As TaskContinuationOptions _
) As Task(Of TResult)
C#
public Task<TResult> ContinueWhenAll(
    Task[] tasks,
    Func<Task[], TResult> continuationFunction,
    TaskContinuationOptions continuationOptions
)

Parameters

tasks
Type: array< System.Threading.Tasks..::.Task >[]()[]
The array of tasks from which to continue.
continuationFunction
Type: System..::.Func<(Of <(array< Task >[]()[], TResult >)>)
The function delegate to execute when all tasks in the tasks array have completed.
continuationOptions
Type: System.Threading.Tasks..::.TaskContinuationOptions
The TaskContinuationOptions value that controls the behavior of the created continuation Task.

Return Value

The new continuation Task.

Remarks

The NotOn* and OnlyOn* TaskContinuationOptions, which constrain for which TaskStatus states a continuation will be executed, are illegal with ContinueWhenAll.

Exceptions

Exception | Condition
System..::.ArgumentNullException | The exception that is thrown when the tasks array is null.
System..::.ArgumentNullException | The exception that is thrown when the continuationFunction argument is null.
System..::.ArgumentException | The exception that is thrown when the tasks array contains a null value.
System..::.ArgumentException | The exception that is thrown when the tasks array is empty.
System..::.ArgumentOutOfRangeException | The exception that is thrown when the continuationOptions argument specifies an invalid TaskContinuationOptions value.
System..::.ObjectDisposedException | The exception that is thrown when one of the elements in the tasks array has been disposed.

See Also

TaskFactory<(Of <(TResult>)>) Class
ContinueWhenAll Overload
System.Threading.Tasks Namespace


ContinueWhenAll(TAntecedentResult) Method (Task(TAntecedentResult)[], Func(Task(TAntecedentResult)[], TResult), CancellationToken)

[image]

.NET Framework Class Library
TaskFactory<(Of <(TResult>)>)..::.ContinueWhenAll<(Of <(TAntecedentResult>)>) Method (array<Task<(Of <(TAntecedentResult>)>)>[]()[], Func<(Of <(array<Task<(Of <(TAntecedentResult>)>)>[]()[], TResult>)>), CancellationToken)
TaskFactory<(Of <(TResult>)>) Class See Also Send Feedback

Creates a continuation Task that will be started upon the completion of a set of provided Tasks.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Function ContinueWhenAll(Of TAntecedentResult) ( _
    tasks As Task(Of TAntecedentResult)(), _
    continuationFunction As Func(Of Task(Of TAntecedentResult)(), TResult), _
    cancellationToken As CancellationToken _
) As Task(Of TResult)
C#
public Task<TResult> ContinueWhenAll<TAntecedentResult>(
    Task<TAntecedentResult>[] tasks,
    Func<Task<TAntecedentResult>[], TResult> continuationFunction,
    CancellationToken cancellationToken
)

Parameters

tasks
Type: array< System.Threading.Tasks..::.Task <(Of <(TAntecedentResult>)>) >[]()[]
The array of tasks from which to continue.
continuationFunction
Type: System..::.Func<(Of <(array< Task <(Of <(TAntecedentResult>)>) >[]()[], TResult >)>)
The function delegate to execute when all tasks in the tasks array have completed.
cancellationToken
Type: System.Threading..::.CancellationToken
The CancellationToken that will be assigned to the new continuation task.

Type Parameters

TAntecedentResult
The type of the result of the antecedent tasks.

Return Value

The new continuation Task<(Of <(TResult>)>).

Exceptions

Exception | Condition
System..::.ArgumentNullException | The exception that is thrown when the tasks array is null.
System..::.ArgumentNullException | The exception that is thrown when the continuationFunction argument is null.
System..::.ArgumentException | The exception that is thrown when the tasks array contains a null value.
System..::.ArgumentException | The exception that is thrown when the tasks array is empty.
System..::.ObjectDisposedException | The exception that is thrown when one of the elements in the tasks array has been disposed.
System..::.ObjectDisposedException | The provided CancellationToken has already been disposed.

See Also

TaskFactory<(Of <(TResult>)>) Class
ContinueWhenAll Overload
System.Threading.Tasks Namespace


ContinueWhenAll(TAntecedentResult) Method (Task(TAntecedentResult)[], Func(Task(TAntecedentResult)[], TResult), TaskContinuationOptions)

[image]

.NET Framework Class Library
TaskFactory<(Of <(TResult>)>)..::.ContinueWhenAll<(Of <(TAntecedentResult>)>) Method (array<Task<(Of <(TAntecedentResult>)>)>[]()[], Func<(Of <(array<Task<(Of <(TAntecedentResult>)>)>[]()[], TResult>)>), TaskContinuationOptions)
TaskFactory<(Of <(TResult>)>) Class See Also Send Feedback

Creates a continuation Task that will be started upon the completion of a set of provided Tasks.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Function ContinueWhenAll(Of TAntecedentResult) ( _
    tasks As Task(Of TAntecedentResult)(), _
    continuationFunction As Func(Of Task(Of TAntecedentResult)(), TResult), _
    continuationOptions As TaskContinuationOptions _
) As Task(Of TResult)
C#
public Task<TResult> ContinueWhenAll<TAntecedentResult>(
    Task<TAntecedentResult>[] tasks,
    Func<Task<TAntecedentResult>[], TResult> continuationFunction,
    TaskContinuationOptions continuationOptions
)

Parameters

tasks
Type: array< System.Threading.Tasks..::.Task <(Of <(TAntecedentResult>)>) >[]()[]
The array of tasks from which to continue.
continuationFunction
Type: System..::.Func<(Of <(array< Task <(Of <(TAntecedentResult>)>) >[]()[], TResult >)>)
The function delegate to execute when all tasks in the tasks array have completed.
continuationOptions
Type: System.Threading.Tasks..::.TaskContinuationOptions
The TaskContinuationOptions value that controls the behavior of the created continuation Task.

Type Parameters

TAntecedentResult
The type of the result of the antecedent tasks.

Return Value

The new continuation Task<(Of <(TResult>)>).

Remarks

The NotOn* and OnlyOn* TaskContinuationOptions, which constrain for which TaskStatus states a continuation will be executed, are illegal with ContinueWhenAll.

Exceptions

Exception | Condition
System..::.ArgumentNullException | The exception that is thrown when the tasks array is null.
System..::.ArgumentNullException | The exception that is thrown when the continuationFunction argument is null.
System..::.ArgumentException | The exception that is thrown when the tasks array contains a null value.
System..::.ArgumentException | The exception that is thrown when the tasks array is empty.
System..::.ArgumentOutOfRangeException | The exception that is thrown when the continuationOptions argument specifies an invalid TaskContinuationOptions value.
System..::.ObjectDisposedException | The exception that is thrown when one of the elements in the tasks array has been disposed.

See Also

TaskFactory<(Of <(TResult>)>) Class
ContinueWhenAll Overload
System.Threading.Tasks Namespace


ContinueWhenAll Method (Task[], Func(Task[], TResult), CancellationToken, TaskContinuationOptions, TaskScheduler)

[image]

.NET Framework Class Library
TaskFactory<(Of <(TResult>)>)..::.ContinueWhenAll Method (array<Task>[]()[], Func<(Of <(array<Task>[]()[], TResult>)>), CancellationToken, TaskContinuationOptions, TaskScheduler)
TaskFactory<(Of <(TResult>)>) Class See Also Send Feedback

Creates a continuation Task that will be started upon the completion of a set of provided Tasks.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Function ContinueWhenAll ( _
    tasks As Task(), _
    continuationFunction As Func(Of Task(), TResult), _
    cancellationToken As CancellationToken, _
    continuationOptions As TaskContinuationOptions, _
    scheduler As TaskScheduler _
) As Task(Of TResult)
C#
public Task<TResult> ContinueWhenAll(
    Task[] tasks,
    Func<Task[], TResult> continuationFunction,
    CancellationToken cancellationToken,
    TaskContinuationOptions continuationOptions,
    TaskScheduler scheduler
)

Parameters

tasks
Type: array< System.Threading.Tasks..::.Task >[]()[]
The array of tasks from which to continue.
continuationFunction
Type: System..::.Func<(Of <(array< Task >[]()[], TResult >)>)
The function delegate to execute when all tasks in the tasks array have completed.
cancellationToken
Type: System.Threading..::.CancellationToken
The CancellationToken that will be assigned to the new continuation task.
continuationOptions
Type: System.Threading.Tasks..::.TaskContinuationOptions
The TaskContinuationOptions value that controls the behavior of the created continuation Task.
scheduler
Type: System.Threading.Tasks..::.TaskScheduler
The TaskScheduler that is used to schedule the created continuation Task.

Return Value

The new continuation Task.

Remarks

The NotOn* and OnlyOn* TaskContinuationOptions, which constrain for which TaskStatus states a continuation will be executed, are illegal with ContinueWhenAll.

Exceptions

Exception | Condition
System..::.ArgumentNullException | The exception that is thrown when the tasks array is null.
System..::.ArgumentNullException | The exception that is thrown when the continuationFunction argument is null.
System..::.ArgumentNullException | The exception that is thrown when the scheduler argument is null.
System..::.ArgumentException | The exception that is thrown when the tasks array contains a null value.
System..::.ArgumentException | The exception that is thrown when the tasks array is empty.
System..::.ArgumentOutOfRangeException | The exception that is thrown when the continuationOptions argument specifies an invalid TaskContinuationOptions value.
System..::.ObjectDisposedException | The exception that is thrown when one of the elements in the tasks array has been disposed.
System..::.ObjectDisposedException | The provided CancellationToken has already been disposed.

See Also

TaskFactory<(Of <(TResult>)>) Class
ContinueWhenAll Overload
System.Threading.Tasks Namespace


ContinueWhenAll(TAntecedentResult) Method (Task(TAntecedentResult)[], Func(Task(TAntecedentResult)[], TResult), CancellationToken, TaskContinuationOptions, TaskScheduler)

[image]

.NET Framework Class Library
TaskFactory<(Of <(TResult>)>)..::.ContinueWhenAll<(Of <(TAntecedentResult>)>) Method (array<Task<(Of <(TAntecedentResult>)>)>[]()[], Func<(Of <(array<Task<(Of <(TAntecedentResult>)>)>[]()[], TResult>)>), CancellationToken, TaskContinuationOptions, TaskScheduler)
TaskFactory<(Of <(TResult>)>) Class See Also Send Feedback

Creates a continuation Task that will be started upon the completion of a set of provided Tasks.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Function ContinueWhenAll(Of TAntecedentResult) ( _
    tasks As Task(Of TAntecedentResult)(), _
    continuationFunction As Func(Of Task(Of TAntecedentResult)(), TResult), _
    cancellationToken As CancellationToken, _
    continuationOptions As TaskContinuationOptions, _
    scheduler As TaskScheduler _
) As Task(Of TResult)
C#
public Task<TResult> ContinueWhenAll<TAntecedentResult>(
    Task<TAntecedentResult>[] tasks,
    Func<Task<TAntecedentResult>[], TResult> continuationFunction,
    CancellationToken cancellationToken,
    TaskContinuationOptions continuationOptions,
    TaskScheduler scheduler
)

Parameters

tasks
Type: array< System.Threading.Tasks..::.Task <(Of <(TAntecedentResult>)>) >[]()[]
The array of tasks from which to continue.
continuationFunction
Type: System..::.Func<(Of <(array< Task <(Of <(TAntecedentResult>)>) >[]()[], TResult >)>)
The function delegate to execute when all tasks in the tasks array have completed.
cancellationToken
Type: System.Threading..::.CancellationToken
The CancellationToken that will be assigned to the new continuation task.
continuationOptions
Type: System.Threading.Tasks..::.TaskContinuationOptions
The TaskContinuationOptions value that controls the behavior of the created continuation Task.
scheduler
Type: System.Threading.Tasks..::.TaskScheduler
The TaskScheduler that is used to schedule the created continuation Task<(Of <(TResult>)>).

Type Parameters

TAntecedentResult
The type of the result of the antecedent tasks.

Return Value

The new continuation Task<(Of <(TResult>)>).

Remarks

The NotOn* and OnlyOn* TaskContinuationOptions, which constrain for which TaskStatus states a continuation will be executed, are illegal with ContinueWhenAll.

Exceptions

Exception | Condition
System..::.ArgumentNullException | The exception that is thrown when the tasks array is null.
System..::.ArgumentNullException | The exception that is thrown when the continuationFunction argument is null.
System..::.ArgumentNullException | The exception that is thrown when the scheduler argument is null.
System..::.ArgumentException | The exception that is thrown when the tasks array contains a null value.
System..::.ArgumentException | The exception that is thrown when the tasks array is empty.
System..::.ArgumentOutOfRangeException | The exception that is thrown when the continuationOptions argument specifies an invalid TaskContinuationOptions value.
System..::.ObjectDisposedException | The exception that is thrown when one of the elements in the tasks array has been disposed.
System..::.ObjectDisposedException | The provided CancellationToken has already been disposed.

See Also

TaskFactory<(Of <(TResult>)>) Class
ContinueWhenAll Overload
System.Threading.Tasks Namespace


ContinueWhenAny Method

[image] [image]

.NET Framework Class Library
TaskFactory<(Of <(TResult>)>)..::.ContinueWhenAny Method
TaskFactory<(Of <(TResult>)>) Class See Also Send Feedback

Overload List

Name | Description
ContinueWhenAny(array<Task>[]()[], Func<(Of <(Task, TResult>)>)) | Creates a continuation Task that will be started upon the completion of any Task in the provided set.
ContinueWhenAny<(Of <(TAntecedentResult>)>)(array<Task<(Of <(TAntecedentResult>)>)>[]()[], Func<(Of <(Task<(Of <(TAntecedentResult>)>), TResult>)>)) | Creates a continuation Task that will be started upon the completion of any Task in the provided set.
ContinueWhenAny(array<Task>[]()[], Func<(Of <(Task, TResult>)>), CancellationToken) | Creates a continuation Task that will be started upon the completion of any Task in the provided set.
ContinueWhenAny(array<Task>[]()[], Func<(Of <(Task, TResult>)>), TaskContinuationOptions) | Creates a continuation Task that will be started upon the completion of any Task in the provided set.
ContinueWhenAny<(Of <(TAntecedentResult>)>)(array<Task<(Of <(TAntecedentResult>)>)>[]()[], Func<(Of <(Task<(Of <(TAntecedentResult>)>), TResult>)>), CancellationToken) | Creates a continuation Task that will be started upon the completion of any Task in the provided set.
ContinueWhenAny<(Of <(TAntecedentResult>)>)(array<Task<(Of <(TAntecedentResult>)>)>[]()[], Func<(Of <(Task<(Of <(TAntecedentResult>)>), TResult>)>), TaskContinuationOptions) | Creates a continuation Task that will be started upon the completion of any Task in the provided set.
ContinueWhenAny(array<Task>[]()[], Func<(Of <(Task, TResult>)>), CancellationToken, TaskContinuationOptions, TaskScheduler) | Creates a continuation Task that will be started upon the completion of any Task in the provided set.
ContinueWhenAny<(Of <(TAntecedentResult>)>)(array<Task<(Of <(TAntecedentResult>)>)>[]()[], Func<(Of <(Task<(Of <(TAntecedentResult>)>), TResult>)>), CancellationToken, TaskContinuationOptions, TaskScheduler) | Creates a continuation Task that will be started upon the completion of any Task in the provided set.

See Also

TaskFactory<(Of <(TResult>)>) Class
System.Threading.Tasks Namespace


ContinueWhenAny Method (Task[], Func(Task, TResult))

[image]

.NET Framework Class Library
TaskFactory<(Of <(TResult>)>)..::.ContinueWhenAny Method (array<Task>[]()[], Func<(Of <(Task, TResult>)>))
TaskFactory<(Of <(TResult>)>) Class See Also Send Feedback

Creates a continuation Task that will be started upon the completion of any Task in the provided set.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Function ContinueWhenAny ( _
    tasks As Task(), _
    continuationFunction As Func(Of Task, TResult) _
) As Task(Of TResult)
C#
public Task<TResult> ContinueWhenAny(
    Task[] tasks,
    Func<Task, TResult> continuationFunction
)

Parameters

tasks
Type: array< System.Threading.Tasks..::.Task >[]()[]
The array of tasks from which to continue when one task completes.
continuationFunction
Type: System..::.Func<(Of <( Task, TResult >)>)
The function delegate to execute when one task in the tasks array completes.

Return Value

The new continuation Task.

Exceptions

Exception | Condition
System..::.ArgumentNullException | The exception that is thrown when the tasks array is null.
System..::.ArgumentNullException | The exception that is thrown when the continuationFunction argument is null.
System..::.ArgumentException | The exception that is thrown when the tasks array contains a null value.
System..::.ArgumentException | The exception that is thrown when the tasks array is empty.
System..::.ObjectDisposedException | The exception that is thrown when one of the elements in the tasks array has been disposed.

See Also

TaskFactory<(Of <(TResult>)>) Class
ContinueWhenAny Overload
System.Threading.Tasks Namespace


ContinueWhenAny(TAntecedentResult) Method (Task(TAntecedentResult)[], Func(Task(TAntecedentResult), TResult))

[image]

.NET Framework Class Library
TaskFactory<(Of <(TResult>)>)..::.ContinueWhenAny<(Of <(TAntecedentResult>)>) Method (array<Task<(Of <(TAntecedentResult>)>)>[]()[], Func<(Of <(Task<(Of <(TAntecedentResult>)>), TResult>)>))
TaskFactory<(Of <(TResult>)>) Class See Also Send Feedback

Creates a continuation Task that will be started upon the completion of any Task in the provided set.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Function ContinueWhenAny(Of TAntecedentResult) ( _
    tasks As Task(Of TAntecedentResult)(), _
    continuationFunction As Func(Of Task(Of TAntecedentResult), TResult) _
) As Task(Of TResult)
C#
public Task<TResult> ContinueWhenAny<TAntecedentResult>(
    Task<TAntecedentResult>[] tasks,
    Func<Task<TAntecedentResult>, TResult> continuationFunction
)

Parameters

tasks
Type: array< System.Threading.Tasks..::.Task <(Of <(TAntecedentResult>)>) >[]()[]
The array of tasks from which to continue when one task completes.
continuationFunction
Type: System..::.Func<(Of <( Task <(Of <(TAntecedentResult>)>), TResult >)>)
The function delegate to execute when one task in the tasks array completes.

Type Parameters

TAntecedentResult
The type of the result of the antecedent tasks.

Return Value

The new continuation Task<(Of <(TResult>)>).

Exceptions

Exception | Condition
System..::.ArgumentNullException | The exception that is thrown when the tasks array is null.
System..::.ArgumentNullException | The exception that is thrown when the continuationFunction argument is null.
System..::.ArgumentException | The exception that is thrown when the tasks array contains a null value.
System..::.ArgumentException | The exception that is thrown when the tasks array is empty.
System..::.ObjectDisposedException | The exception that is thrown when one of the elements in the tasks array has been disposed.

See Also

TaskFactory<(Of <(TResult>)>) Class
ContinueWhenAny Overload
System.Threading.Tasks Namespace


ContinueWhenAny Method (Task[], Func(Task, TResult), CancellationToken)

[image]

.NET Framework Class Library
TaskFactory<(Of <(TResult>)>)..::.ContinueWhenAny Method (array<Task>[]()[], Func<(Of <(Task, TResult>)>), CancellationToken)
TaskFactory<(Of <(TResult>)>) Class See Also Send Feedback

Creates a continuation Task that will be started upon the completion of any Task in the provided set.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Function ContinueWhenAny ( _
    tasks As Task(), _
    continuationFunction As Func(Of Task, TResult), _
    cancellationToken As CancellationToken _
) As Task(Of TResult)
C#
public Task<TResult> ContinueWhenAny(
    Task[] tasks,
    Func<Task, TResult> continuationFunction,
    CancellationToken cancellationToken
)

Parameters

tasks
Type: array< System.Threading.Tasks..::.Task >[]()[]
The array of tasks from which to continue when one task completes.
continuationFunction
Type: System..::.Func<(Of <( Task, TResult >)>)
The function delegate to execute when one task in the tasks array completes.
cancellationToken
Type: System.Threading..::.CancellationToken
The CancellationToken that will be assigned to the new continuation task.

Return Value

The new continuation Task.

Exceptions

Exception | Condition
System..::.ArgumentNullException | The exception that is thrown when the tasks array is null.
System..::.ArgumentNullException | The exception that is thrown when the continuationFunction argument is null.
System..::.ArgumentException | The exception that is thrown when the tasks array contains a null value.
System..::.ArgumentException | The exception that is thrown when the tasks array is empty.
System..::.ObjectDisposedException | The exception that is thrown when one of the elements in the tasks array has been disposed.
System..::.ObjectDisposedException | The provided CancellationToken has already been disposed.

See Also

TaskFactory<(Of <(TResult>)>) Class
ContinueWhenAny Overload
System.Threading.Tasks Namespace


ContinueWhenAny Method (Task[], Func(Task, TResult), TaskContinuationOptions)

[image]

.NET Framework Class Library
TaskFactory<(Of <(TResult>)>)..::.ContinueWhenAny Method (array<Task>[]()[], Func<(Of <(Task, TResult>)>), TaskContinuationOptions)
TaskFactory<(Of <(TResult>)>) Class See Also Send Feedback

Creates a continuation Task that will be started upon the completion of any Task in the provided set.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Function ContinueWhenAny ( _
    tasks As Task(), _
    continuationFunction As Func(Of Task, TResult), _
    continuationOptions As TaskContinuationOptions _
) As Task(Of TResult)
C#
public Task<TResult> ContinueWhenAny(
    Task[] tasks,
    Func<Task, TResult> continuationFunction,
    TaskContinuationOptions continuationOptions
)

Parameters

tasks
Type: array< System.Threading.Tasks..::.Task >[]()[]
The array of tasks from which to continue when one task completes.
continuationFunction
Type: System..::.Func<(Of <( Task, TResult >)>)
The function delegate to execute when one task in the tasks array completes.
continuationOptions
Type: System.Threading.Tasks..::.TaskContinuationOptions
The TaskContinuationOptions value that controls the behavior of the created continuation Task.

Return Value

The new continuation Task.

Remarks

The NotOn* and OnlyOn* TaskContinuationOptions, which constrain for which TaskStatus states a continuation will be executed, are illegal with ContinueWhenAny.

Exceptions

Exception | Condition
System..::.ArgumentNullException | The exception that is thrown when the tasks array is null.
System..::.ArgumentNullException | The exception that is thrown when the continuationFunction argument is null.
System..::.ArgumentException | The exception that is thrown when the tasks array contains a null value.
System..::.ArgumentException | The exception that is thrown when the tasks array is empty.
System..::.ArgumentOutOfRangeException | The exception that is thrown when the continuationOptions argument specifies an invalid TaskContinuationOptions value.
System..::.ObjectDisposedException | The exception that is thrown when one of the elements in the tasks array has been disposed.

See Also

TaskFactory<(Of <(TResult>)>) Class
ContinueWhenAny Overload
System.Threading.Tasks Namespace


ContinueWhenAny(TAntecedentResult) Method (Task(TAntecedentResult)[], Func(Task(TAntecedentResult), TResult), CancellationToken)

[image]

.NET Framework Class Library
TaskFactory<(Of <(TResult>)>)..::.ContinueWhenAny<(Of <(TAntecedentResult>)>) Method (array<Task<(Of <(TAntecedentResult>)>)>[]()[], Func<(Of <(Task<(Of <(TAntecedentResult>)>), TResult>)>), CancellationToken)
TaskFactory<(Of <(TResult>)>) Class See Also Send Feedback

Creates a continuation Task that will be started upon the completion of any Task in the provided set.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Function ContinueWhenAny(Of TAntecedentResult) ( _
    tasks As Task(Of TAntecedentResult)(), _
    continuationFunction As Func(Of Task(Of TAntecedentResult), TResult), _
    cancellationToken As CancellationToken _
) As Task(Of TResult)
C#
public Task<TResult> ContinueWhenAny<TAntecedentResult>(
    Task<TAntecedentResult>[] tasks,
    Func<Task<TAntecedentResult>, TResult> continuationFunction,
    CancellationToken cancellationToken
)

Parameters

tasks
Type: array< System.Threading.Tasks..::.Task <(Of <(TAntecedentResult>)>) >[]()[]
The array of tasks from which to continue when one task completes.
continuationFunction
Type: System..::.Func<(Of <( Task <(Of <(TAntecedentResult>)>), TResult >)>)
The function delegate to execute when one task in the tasks array completes.
cancellationToken
Type: System.Threading..::.CancellationToken
The CancellationToken that will be assigned to the new continuation task.

Type Parameters

TAntecedentResult
The type of the result of the antecedent tasks.

Return Value

The new continuation Task<(Of <(TResult>)>).

Exceptions

Exception | Condition
System..::.ArgumentNullException | The exception that is thrown when the tasks array is null.
System..::.ArgumentNullException | The exception that is thrown when the continuationFunction argument is null.
System..::.ArgumentException | The exception that is thrown when the tasks array contains a null value.
System..::.ArgumentException | The exception that is thrown when the tasks array is empty.
System..::.ObjectDisposedException | The exception that is thrown when one of the elements in the tasks array has been disposed.
System..::.ObjectDisposedException | The provided CancellationToken has already been disposed.

See Also

TaskFactory<(Of <(TResult>)>) Class
ContinueWhenAny Overload
System.Threading.Tasks Namespace


ContinueWhenAny(TAntecedentResult) Method (Task(TAntecedentResult)[], Func(Task(TAntecedentResult), TResult), TaskContinuationOptions)

[image]

.NET Framework Class Library
TaskFactory<(Of <(TResult>)>)..::.ContinueWhenAny<(Of <(TAntecedentResult>)>) Method (array<Task<(Of <(TAntecedentResult>)>)>[]()[], Func<(Of <(Task<(Of <(TAntecedentResult>)>), TResult>)>), TaskContinuationOptions)
TaskFactory<(Of <(TResult>)>) Class See Also Send Feedback

Creates a continuation Task that will be started upon the completion of any Task in the provided set.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Function ContinueWhenAny(Of TAntecedentResult) ( _
    tasks As Task(Of TAntecedentResult)(), _
    continuationFunction As Func(Of Task(Of TAntecedentResult), TResult), _
    continuationOptions As TaskContinuationOptions _
) As Task(Of TResult)
C#
public Task<TResult> ContinueWhenAny<TAntecedentResult>(
    Task<TAntecedentResult>[] tasks,
    Func<Task<TAntecedentResult>, TResult> continuationFunction,
    TaskContinuationOptions continuationOptions
)

Parameters

tasks
Type: array< System.Threading.Tasks..::.Task <(Of <(TAntecedentResult>)>) >[]()[]
The array of tasks from which to continue when one task completes.
continuationFunction
Type: System..::.Func<(Of <( Task <(Of <(TAntecedentResult>)>), TResult >)>)
The function delegate to execute when one task in the tasks array completes.
continuationOptions
Type: System.Threading.Tasks..::.TaskContinuationOptions
The TaskContinuationOptions value that controls the behavior of the created continuation Task.

Type Parameters

TAntecedentResult
The type of the result of the antecedent tasks.

Return Value

The new continuation Task<(Of <(TResult>)>).

Remarks

The NotOn* and OnlyOn* TaskContinuationOptions, which constrain for which TaskStatus states a continuation will be executed, are illegal with ContinueWhenAny.

Exceptions

Exception | Condition
System..::.ArgumentNullException | The exception that is thrown when the tasks array is null.
System..::.ArgumentNullException | The exception that is thrown when the continuationFunction argument is null.
System..::.ArgumentException | The exception that is thrown when the tasks array contains a null value.
System..::.ArgumentException | The exception that is thrown when the tasks array is empty.
System..::.ArgumentOutOfRangeException | The exception that is thrown when the continuationOptions argument specifies an invalid TaskContinuationOptions value.
System..::.ObjectDisposedException | The exception that is thrown when one of the elements in the tasks array has been disposed.

See Also

TaskFactory<(Of <(TResult>)>) Class
ContinueWhenAny Overload
System.Threading.Tasks Namespace


ContinueWhenAny Method (Task[], Func(Task, TResult), CancellationToken, TaskContinuationOptions, TaskScheduler)

[image]

.NET Framework Class Library
TaskFactory<(Of <(TResult>)>)..::.ContinueWhenAny Method (array<Task>[]()[], Func<(Of <(Task, TResult>)>), CancellationToken, TaskContinuationOptions, TaskScheduler)
TaskFactory<(Of <(TResult>)>) Class See Also Send Feedback

Creates a continuation Task that will be started upon the completion of any Task in the provided set.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Function ContinueWhenAny ( _
    tasks As Task(), _
    continuationFunction As Func(Of Task, TResult), _
    cancellationToken As CancellationToken, _
    continuationOptions As TaskContinuationOptions, _
    scheduler As TaskScheduler _
) As Task(Of TResult)
C#
public Task<TResult> ContinueWhenAny(
    Task[] tasks,
    Func<Task, TResult> continuationFunction,
    CancellationToken cancellationToken,
    TaskContinuationOptions continuationOptions,
    TaskScheduler scheduler
)

Parameters

tasks
Type: array< System.Threading.Tasks..::.Task >[]()[]
The array of tasks from which to continue when one task completes.
continuationFunction
Type: System..::.Func<(Of <( Task, TResult >)>)
The function delegate to execute when one task in the tasks array completes.
cancellationToken
Type: System.Threading..::.CancellationToken
The CancellationToken that will be assigned to the new continuation task.
continuationOptions
Type: System.Threading.Tasks..::.TaskContinuationOptions
The TaskContinuationOptions value that controls the behavior of the created continuation Task.
scheduler
Type: System.Threading.Tasks..::.TaskScheduler
The TaskScheduler that is used to schedule the created continuation Task.

Return Value

The new continuation Task.

Remarks

The NotOn* and OnlyOn* TaskContinuationOptions, which constrain for which TaskStatus states a continuation will be executed, are illegal with ContinueWhenAny.

Exceptions

Exception | Condition
System..::.ArgumentNullException | The exception that is thrown when the tasks array is null.
System..::.ArgumentNullException | The exception that is thrown when the continuationFunction argument is null.
System..::.ArgumentNullException | The exception that is thrown when the scheduler argument is null.
System..::.ArgumentException | The exception that is thrown when the tasks array contains a null value.
System..::.ArgumentException | The exception that is thrown when the tasks array is empty.
System..::.ArgumentOutOfRangeException | The exception that is thrown when the continuationOptions argument specifies an invalid TaskContinuationOptions value.
System..::.ObjectDisposedException | The exception that is thrown when one of the elements in the tasks array has been disposed.
System..::.ObjectDisposedException | The provided CancellationToken has already been disposed.

See Also

TaskFactory<(Of <(TResult>)>) Class
ContinueWhenAny Overload
System.Threading.Tasks Namespace


ContinueWhenAny(TAntecedentResult) Method (Task(TAntecedentResult)[], Func(Task(TAntecedentResult), TResult), CancellationToken, TaskContinuationOptions, TaskScheduler)

[image]

.NET Framework Class Library
TaskFactory<(Of <(TResult>)>)..::.ContinueWhenAny<(Of <(TAntecedentResult>)>) Method (array<Task<(Of <(TAntecedentResult>)>)>[]()[], Func<(Of <(Task<(Of <(TAntecedentResult>)>), TResult>)>), CancellationToken, TaskContinuationOptions, TaskScheduler)
TaskFactory<(Of <(TResult>)>) Class See Also Send Feedback

Creates a continuation Task that will be started upon the completion of any Task in the provided set.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Function ContinueWhenAny(Of TAntecedentResult) ( _
    tasks As Task(Of TAntecedentResult)(), _
    continuationFunction As Func(Of Task(Of TAntecedentResult), TResult), _
    cancellationToken As CancellationToken, _
    continuationOptions As TaskContinuationOptions, _
    scheduler As TaskScheduler _
) As Task(Of TResult)
C#
public Task<TResult> ContinueWhenAny<TAntecedentResult>(
    Task<TAntecedentResult>[] tasks,
    Func<Task<TAntecedentResult>, TResult> continuationFunction,
    CancellationToken cancellationToken,
    TaskContinuationOptions continuationOptions,
    TaskScheduler scheduler
)

Parameters

tasks
Type: array< System.Threading.Tasks..::.Task <(Of <(TAntecedentResult>)>) >[]()[]
The array of tasks from which to continue when one task completes.
continuationFunction
Type: System..::.Func<(Of <( Task <(Of <(TAntecedentResult>)>), TResult >)>)
The function delegate to execute when one task in the tasks array completes.
cancellationToken
Type: System.Threading..::.CancellationToken
The CancellationToken that will be assigned to the new continuation task.
continuationOptions
Type: System.Threading.Tasks..::.TaskContinuationOptions
The TaskContinuationOptions value that controls the behavior of the created continuation Task.
scheduler
Type: System.Threading.Tasks..::.TaskScheduler
The TaskScheduler that is used to schedule the created continuation Task<(Of <(TResult>)>).

Type Parameters

TAntecedentResult
The type of the result of the antecedent tasks.

Return Value

The new continuation Task<(Of <(TResult>)>).

Remarks

The NotOn* and OnlyOn* TaskContinuationOptions, which constrain for which TaskStatus states a continuation will be executed, are illegal with ContinueWhenAny.

Exceptions

Exception | Condition
System..::.ArgumentNullException | The exception that is thrown when the tasks array is null.
System..::.ArgumentNullException | The exception that is thrown when the continuationFunction argument is null.
System..::.ArgumentNullException | The exception that is thrown when the scheduler argument is null.
System..::.ArgumentException | The exception that is thrown when the tasks array contains a null value.
System..::.ArgumentException | The exception that is thrown when the tasks array is empty.
System..::.ArgumentOutOfRangeException | The exception that is thrown when the continuationOptions argument specifies an invalid TaskContinuationOptions value.
System..::.ObjectDisposedException | The exception that is thrown when one of the elements in the tasks array has been disposed.
System..::.ObjectDisposedException | The provided CancellationToken has already been disposed.

See Also

TaskFactory<(Of <(TResult>)>) Class
ContinueWhenAny Overload
System.Threading.Tasks Namespace


FromAsync Method

[image] [image]

.NET Framework Class Library
TaskFactory<(Of <(TResult>)>)..::.FromAsync Method
TaskFactory<(Of <(TResult>)>) Class See Also Send Feedback

Overload List

Name | Description
FromAsync(IAsyncResult, Func<(Of <(IAsyncResult, TResult>)>)) | Creates a Task that executes an end method function when a specified IAsyncResult completes.
FromAsync(Func<(Of <(AsyncCallback, Object, IAsyncResult>)>), Func<(Of <(IAsyncResult, TResult>)>), Object) | Creates a Task that represents a pair of begin and end methods that conform to the Asynchronous Programming Model pattern.
FromAsync(IAsyncResult, Func<(Of <(IAsyncResult, TResult>)>), TaskCreationOptions) | Creates a Task that executes an end method function when a specified IAsyncResult completes.
FromAsync(Func<(Of <(AsyncCallback, Object, IAsyncResult>)>), Func<(Of <(IAsyncResult, TResult>)>), Object, TaskCreationOptions) | Creates a Task that represents a pair of begin and end methods that conform to the Asynchronous Programming Model pattern.
FromAsync<(Of <(TArg1>)>)(Func<(Of <(TArg1, AsyncCallback, Object, IAsyncResult>)>), Func<(Of <(IAsyncResult, TResult>)>), TArg1, Object) | Creates a Task that represents a pair of begin and end methods that conform to the Asynchronous Programming Model pattern.
FromAsync(IAsyncResult, Func<(Of <(IAsyncResult, TResult>)>), TaskCreationOptions, TaskScheduler) | Creates a Task that executes an end method function when a specified IAsyncResult completes.
FromAsync<(Of <(TArg1>)>)(Func<(Of <(TArg1, AsyncCallback, Object, IAsyncResult>)>), Func<(Of <(IAsyncResult, TResult>)>), TArg1, Object, TaskCreationOptions) | Creates a Task that represents a pair of begin and end methods that conform to the Asynchronous Programming Model pattern.
FromAsync<(Of <(TArg1, TArg2>)>)(Func<(Of <(TArg1, TArg2, AsyncCallback, Object, IAsyncResult>)>), Func<(Of <(IAsyncResult, TResult>)>), TArg1, TArg2, Object) | Creates a Task that represents a pair of begin and end methods that conform to the Asynchronous Programming Model pattern.
FromAsync<(Of <(TArg1, TArg2, TArg3>)>)(Func_<(Of <(TArg1, TArg2, TArg3, AsyncCallback, Object, IAsyncResult>)>), Func<(Of <(IAsyncResult, TResult>)>), TArg1, TArg2, TArg3, Object) | Creates a Task that represents a pair of begin and end methods that conform to the Asynchronous Programming Model pattern.
FromAsync<(Of <(TArg1, TArg2>)>)(Func<(Of <(TArg1, TArg2, AsyncCallback, Object, IAsyncResult>)>), Func<(Of <(IAsyncResult, TResult>)>), TArg1, TArg2, Object, TaskCreationOptions) | Creates a Task that represents a pair of begin and end methods that conform to the Asynchronous Programming Model pattern.
FromAsync<(Of <(TArg1, TArg2, TArg3>)>)(Func_<(Of <(TArg1, TArg2, TArg3, AsyncCallback, Object, IAsyncResult>)>), Func<(Of <(IAsyncResult, TResult>)>), TArg1, TArg2, TArg3, Object, TaskCreationOptions) | Creates a Task that represents a pair of begin and end methods that conform to the Asynchronous Programming Model pattern.

See Also

TaskFactory<(Of <(TResult>)>) Class
System.Threading.Tasks Namespace


FromAsync Method (IAsyncResult, Func(IAsyncResult, TResult))

[image]

.NET Framework Class Library
TaskFactory<(Of <(TResult>)>)..::.FromAsync Method (IAsyncResult, Func<(Of <(IAsyncResult, TResult>)>))
TaskFactory<(Of <(TResult>)>) Class See Also Send Feedback

Creates a Task that executes an end method function when a specified IAsyncResult completes.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Function FromAsync ( _
    asyncResult As IAsyncResult, _
    endMethod As Func(Of IAsyncResult, TResult) _
) As Task(Of TResult)
C#
public Task<TResult> FromAsync(
    IAsyncResult asyncResult,
    Func<IAsyncResult, TResult> endMethod
)

Parameters

asyncResult
Type: System..::.IAsyncResult
The IAsyncResult whose completion should trigger the processing of the endMethod.
endMethod
Type: System..::.Func<(Of <(IAsyncResult, TResult >)>)
The function delegate that processes the completed asyncResult.

Return Value

A Task that represents the asynchronous operation.

Exceptions

Exception | Condition
System..::.ArgumentNullException | The exception that is thrown when the asyncResult argument is null.
System..::.ArgumentNullException | The exception that is thrown when the endMethod argument is null.

See Also

TaskFactory<(Of <(TResult>)>) Class
FromAsync Overload
System.Threading.Tasks Namespace


FromAsync Method (Func(AsyncCallback, Object, IAsyncResult), Func(IAsyncResult, TResult), Object)

[image]

.NET Framework Class Library
TaskFactory<(Of <(TResult>)>)..::.FromAsync Method (Func<(Of <(AsyncCallback, Object, IAsyncResult>)>), Func<(Of <(IAsyncResult, TResult>)>), Object)
TaskFactory<(Of <(TResult>)>) Class See Also Send Feedback

Creates a Task that represents a pair of begin and end methods that conform to the Asynchronous Programming Model pattern.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Function FromAsync ( _
    beginMethod As Func(Of AsyncCallback, Object, IAsyncResult), _
    endMethod As Func(Of IAsyncResult, TResult), _
    state As Object _
) As Task(Of TResult)
C#
public Task<TResult> FromAsync(
    Func<AsyncCallback, Object, IAsyncResult> beginMethod,
    Func<IAsyncResult, TResult> endMethod,
    Object state
)

Parameters

beginMethod
Type: System..::.Func<(Of <(AsyncCallback, Object, IAsyncResult>)>)
The delegate that begins the asynchronous operation.
endMethod
Type: System..::.Func<(Of <(IAsyncResult, TResult >)>)
The delegate that ends the asynchronous operation.
state
Type: System..::.Object
An object containing data to be used by the beginMethod delegate.

Return Value

The created Task that represents the asynchronous operation.

Remarks

This method throws any exceptions thrown by the beginMethod.

Exceptions

Exception | Condition
System..::.ArgumentNullException | The exception that is thrown when the beginMethod argument is null.
System..::.ArgumentNullException | The exception that is thrown when the endMethod argument is null.

See Also

TaskFactory<(Of <(TResult>)>) Class
FromAsync Overload
System.Threading.Tasks Namespace


FromAsync Method (IAsyncResult, Func(IAsyncResult, TResult), TaskCreationOptions)

[image]

.NET Framework Class Library
TaskFactory<(Of <(TResult>)>)..::.FromAsync Method (IAsyncResult, Func<(Of <(IAsyncResult, TResult>)>), TaskCreationOptions)
TaskFactory<(Of <(TResult>)>) Class See Also Send Feedback

Creates a Task that executes an end method function when a specified IAsyncResult completes.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Function FromAsync ( _
    asyncResult As IAsyncResult, _
    endMethod As Func(Of IAsyncResult, TResult), _
    creationOptions As TaskCreationOptions _
) As Task(Of TResult)
C#
public Task<TResult> FromAsync(
    IAsyncResult asyncResult,
    Func<IAsyncResult, TResult> endMethod,
    TaskCreationOptions creationOptions
)

Parameters

asyncResult
Type: System..::.IAsyncResult
The IAsyncResult whose completion should trigger the processing of the endMethod.
endMethod
Type: System..::.Func<(Of <(IAsyncResult, TResult >)>)
The function delegate that processes the completed asyncResult.
creationOptions
Type: System.Threading.Tasks..::.TaskCreationOptions
The TaskCreationOptions value that controls the behavior of the created Task.

Return Value

A Task that represents the asynchronous operation.

Exceptions

Exception | Condition
System..::.ArgumentNullException | The exception that is thrown when the asyncResult argument is null.
System..::.ArgumentNullException | The exception that is thrown when the endMethod argument is null.
System..::.ArgumentOutOfRangeException | The exception that is thrown when the creationOptions argument specifies an invalid TaskCreationOptions value.

See Also

TaskFactory<(Of <(TResult>)>) Class
FromAsync Overload
System.Threading.Tasks Namespace


FromAsync Method (Func(AsyncCallback, Object, IAsyncResult), Func(IAsyncResult, TResult), Object, TaskCreationOptions)

[image]

.NET Framework Class Library
TaskFactory<(Of <(TResult>)>)..::.FromAsync Method (Func<(Of <(AsyncCallback, Object, IAsyncResult>)>), Func<(Of <(IAsyncResult, TResult>)>), Object, TaskCreationOptions)
TaskFactory<(Of <(TResult>)>) Class See Also Send Feedback

Creates a Task that represents a pair of begin and end methods that conform to the Asynchronous Programming Model pattern.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Function FromAsync ( _
    beginMethod As Func(Of AsyncCallback, Object, IAsyncResult), _
    endMethod As Func(Of IAsyncResult, TResult), _
    state As Object, _
    creationOptions As TaskCreationOptions _
) As Task(Of TResult)
C#
public Task<TResult> FromAsync(
    Func<AsyncCallback, Object, IAsyncResult> beginMethod,
    Func<IAsyncResult, TResult> endMethod,
    Object state,
    TaskCreationOptions creationOptions
)

Parameters

beginMethod
Type: System..::.Func<(Of <(AsyncCallback, Object, IAsyncResult>)>)
The delegate that begins the asynchronous operation.
endMethod
Type: System..::.Func<(Of <(IAsyncResult, TResult >)>)
The delegate that ends the asynchronous operation.
state
Type: System..::.Object
An object containing data to be used by the beginMethod delegate.
creationOptions
Type: System.Threading.Tasks..::.TaskCreationOptions
The TaskCreationOptions value that controls the behavior of the created Task.

Return Value

The created Task that represents the asynchronous operation.

Remarks

This method throws any exceptions thrown by the beginMethod.

Exceptions

Exception | Condition
System..::.ArgumentNullException | The exception that is thrown when the beginMethod argument is null.
System..::.ArgumentNullException | The exception that is thrown when the endMethod argument is null.
System..::.ArgumentOutOfRangeException | The exception that is thrown when the creationOptions argument specifies an invalid TaskCreationOptions value.

See Also

TaskFactory<(Of <(TResult>)>) Class
FromAsync Overload
System.Threading.Tasks Namespace


FromAsync(TArg1) Method (Func(TArg1, AsyncCallback, Object, IAsyncResult), Func(IAsyncResult, TResult), TArg1, Object)

[image]

.NET Framework Class Library
TaskFactory<(Of <(TResult>)>)..::.FromAsync<(Of <(TArg1>)>) Method (Func<(Of <(TArg1, AsyncCallback, Object, IAsyncResult>)>), Func<(Of <(IAsyncResult, TResult>)>), TArg1, Object)
TaskFactory<(Of <(TResult>)>) Class See Also Send Feedback

Creates a Task that represents a pair of begin and end methods that conform to the Asynchronous Programming Model pattern.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Function FromAsync(Of TArg1) ( _
    beginMethod As Func(Of TArg1, AsyncCallback, Object, IAsyncResult), _
    endMethod As Func(Of IAsyncResult, TResult), _
    arg1 As TArg1, _
    state As Object _
) As Task(Of TResult)
C#
public Task<TResult> FromAsync<TArg1>(
    Func<TArg1, AsyncCallback, Object, IAsyncResult> beginMethod,
    Func<IAsyncResult, TResult> endMethod,
    TArg1 arg1,
    Object state
)

Parameters

beginMethod
Type: System..::.Func<(Of <(TArg1, AsyncCallback, Object, IAsyncResult>)>)
The delegate that begins the asynchronous operation.
endMethod
Type: System..::.Func<(Of <(IAsyncResult, TResult >)>)
The delegate that ends the asynchronous operation.
arg1
Type: TArg1
The first argument passed to the beginMethod delegate.
state
Type: System..::.Object
An object containing data to be used by the beginMethod delegate.

Type Parameters

TArg1
The type of the first argument passed to the beginMethod delegate.

Return Value

The created Task that represents the asynchronous operation.

Remarks

This method throws any exceptions thrown by the beginMethod.

Exceptions

Exception | Condition
System..::.ArgumentNullException | The exception that is thrown when the beginMethod argument is null.
System..::.ArgumentNullException | The exception that is thrown when the endMethod argument is null.

See Also

TaskFactory<(Of <(TResult>)>) Class
FromAsync Overload
System.Threading.Tasks Namespace


FromAsync Method (IAsyncResult, Func(IAsyncResult, TResult), TaskCreationOptions, TaskScheduler)

[image]

.NET Framework Class Library
TaskFactory<(Of <(TResult>)>)..::.FromAsync Method (IAsyncResult, Func<(Of <(IAsyncResult, TResult>)>), TaskCreationOptions, TaskScheduler)
TaskFactory<(Of <(TResult>)>) Class See Also Send Feedback

Creates a Task that executes an end method function when a specified IAsyncResult completes.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Function FromAsync ( _
    asyncResult As IAsyncResult, _
    endMethod As Func(Of IAsyncResult, TResult), _
    creationOptions As TaskCreationOptions, _
    scheduler As TaskScheduler _
) As Task(Of TResult)
C#
public Task<TResult> FromAsync(
    IAsyncResult asyncResult,
    Func<IAsyncResult, TResult> endMethod,
    TaskCreationOptions creationOptions,
    TaskScheduler scheduler
)

Parameters

asyncResult
Type: System..::.IAsyncResult
The IAsyncResult whose completion should trigger the processing of the endMethod.
endMethod
Type: System..::.Func<(Of <(IAsyncResult, TResult >)>)
The function delegate that processes the completed asyncResult.
creationOptions
Type: System.Threading.Tasks..::.TaskCreationOptions
The TaskCreationOptions value that controls the behavior of the created Task.
scheduler
Type: System.Threading.Tasks..::.TaskScheduler
The TaskScheduler that is used to schedule the task that executes the end method.

Return Value

A Task that represents the asynchronous operation.

Exceptions

Exception | Condition
System..::.ArgumentNullException | The exception that is thrown when the asyncResult argument is null.
System..::.ArgumentNullException | The exception that is thrown when the endMethod argument is null.
System..::.ArgumentNullException | The exception that is thrown when the scheduler argument is null.
System..::.ArgumentOutOfRangeException | The exception that is thrown when the creationOptions argument specifies an invalid TaskCreationOptions value.

See Also

TaskFactory<(Of <(TResult>)>) Class
FromAsync Overload
System.Threading.Tasks Namespace


FromAsync(TArg1) Method (Func(TArg1, AsyncCallback, Object, IAsyncResult), Func(IAsyncResult, TResult), TArg1, Object, TaskCreationOptions)

[image]

.NET Framework Class Library
TaskFactory<(Of <(TResult>)>)..::.FromAsync<(Of <(TArg1>)>) Method (Func<(Of <(TArg1, AsyncCallback, Object, IAsyncResult>)>), Func<(Of <(IAsyncResult, TResult>)>), TArg1, Object, TaskCreationOptions)
TaskFactory<(Of <(TResult>)>) Class See Also Send Feedback

Creates a Task that represents a pair of begin and end methods that conform to the Asynchronous Programming Model pattern.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Function FromAsync(Of TArg1) ( _
    beginMethod As Func(Of TArg1, AsyncCallback, Object, IAsyncResult), _
    endMethod As Func(Of IAsyncResult, TResult), _
    arg1 As TArg1, _
    state As Object, _
    creationOptions As TaskCreationOptions _
) As Task(Of TResult)
C#
public Task<TResult> FromAsync<TArg1>(
    Func<TArg1, AsyncCallback, Object, IAsyncResult> beginMethod,
    Func<IAsyncResult, TResult> endMethod,
    TArg1 arg1,
    Object state,
    TaskCreationOptions creationOptions
)

Parameters

beginMethod
Type: System..::.Func<(Of <(TArg1, AsyncCallback, Object, IAsyncResult>)>)
The delegate that begins the asynchronous operation.
endMethod
Type: System..::.Func<(Of <(IAsyncResult, TResult >)>)
The delegate that ends the asynchronous operation.
arg1
Type: TArg1
The first argument passed to the beginMethod delegate.
state
Type: System..::.Object
An object containing data to be used by the beginMethod delegate.
creationOptions
Type: System.Threading.Tasks..::.TaskCreationOptions
The TaskCreationOptions value that controls the behavior of the created Task.

Type Parameters

TArg1
The type of the first argument passed to the beginMethod delegate.

Return Value

The created Task that represents the asynchronous operation.

Remarks

This method throws any exceptions thrown by the beginMethod.

Exceptions

Exception | Condition
System..::.ArgumentNullException | The exception that is thrown when the beginMethod argument is null.
System..::.ArgumentNullException | The exception that is thrown when the endMethod argument is null.
System..::.ArgumentOutOfRangeException | The exception that is thrown when the creationOptions argument specifies an invalid TaskCreationOptions value.

See Also

TaskFactory<(Of <(TResult>)>) Class
FromAsync Overload
System.Threading.Tasks Namespace


FromAsync(TArg1, TArg2) Method (Func(TArg1, TArg2, AsyncCallback, Object, IAsyncResult), Func(IAsyncResult, TResult), TArg1, TArg2, Object)

[image]

.NET Framework Class Library
TaskFactory<(Of <(TResult>)>)..::.FromAsync<(Of <(TArg1, TArg2>)>) Method (Func<(Of <(TArg1, TArg2, AsyncCallback, Object, IAsyncResult>)>), Func<(Of <(IAsyncResult, TResult>)>), TArg1, TArg2, Object)
TaskFactory<(Of <(TResult>)>) Class See Also Send Feedback

Creates a Task that represents a pair of begin and end methods that conform to the Asynchronous Programming Model pattern.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Function FromAsync(Of TArg1, TArg2) ( _
    beginMethod As Func(Of TArg1, TArg2, AsyncCallback, Object, IAsyncResult), _
    endMethod As Func(Of IAsyncResult, TResult), _
    arg1 As TArg1, _
    arg2 As TArg2, _
    state As Object _
) As Task(Of TResult)
C#
public Task<TResult> FromAsync<TArg1, TArg2>(
    Func<TArg1, TArg2, AsyncCallback, Object, IAsyncResult> beginMethod,
    Func<IAsyncResult, TResult> endMethod,
    TArg1 arg1,
    TArg2 arg2,
    Object state
)

Parameters

beginMethod
Type: System..::.Func<(Of <(TArg1, TArg2, AsyncCallback, Object, IAsyncResult>)>)
The delegate that begins the asynchronous operation.
endMethod
Type: System..::.Func<(Of <(IAsyncResult, TResult >)>)
The delegate that ends the asynchronous operation.
arg1
Type: TArg1
The first argument passed to the beginMethod delegate.
arg2
Type: TArg2
The second argument passed to the beginMethod delegate.
state
Type: System..::.Object
An object containing data to be used by the beginMethod delegate.

Type Parameters

TArg1
The type of the first argument passed to the beginMethod delegate.
TArg2
The type of the second argument passed to beginMethod delegate.

Return Value

The created Task that represents the asynchronous operation.

Remarks

This method throws any exceptions thrown by the beginMethod.

Exceptions

Exception | Condition
System..::.ArgumentNullException | The exception that is thrown when the beginMethod argument is null.
System..::.ArgumentNullException | The exception that is thrown when the endMethod argument is null.

See Also

TaskFactory<(Of <(TResult>)>) Class
FromAsync Overload
System.Threading.Tasks Namespace


FromAsync(TArg1, TArg2, TArg3) Method (Func_(TArg1, TArg2, TArg3, AsyncCallback, Object, IAsyncResult), Func(IAsyncResult, TResult), TArg1, TArg2, TArg3, Object)

[image]

.NET Framework Class Library
TaskFactory<(Of <(TResult>)>)..::.FromAsync<(Of <(TArg1, TArg2, TArg3>)>) Method (Func_<(Of <(TArg1, TArg2, TArg3, AsyncCallback, Object, IAsyncResult>)>), Func<(Of <(IAsyncResult, TResult>)>), TArg1, TArg2, TArg3, Object)
TaskFactory<(Of <(TResult>)>) Class See Also Send Feedback

Creates a Task that represents a pair of begin and end methods that conform to the Asynchronous Programming Model pattern.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Function FromAsync(Of TArg1, TArg2, TArg3) ( _
    beginMethod As Func_(Of TArg1, TArg2, TArg3, AsyncCallback, Object, IAsyncResult), _
    endMethod As Func(Of IAsyncResult, TResult), _
    arg1 As TArg1, _
    arg2 As TArg2, _
    arg3 As TArg3, _
    state As Object _
) As Task(Of TResult)
C#
public Task<TResult> FromAsync<TArg1, TArg2, TArg3>(
    Func_<TArg1, TArg2, TArg3, AsyncCallback, Object, IAsyncResult> beginMethod,
    Func<IAsyncResult, TResult> endMethod,
    TArg1 arg1,
    TArg2 arg2,
    TArg3 arg3,
    Object state
)

Parameters

beginMethod
Type: System..::.Func_ <(Of <(TArg1, TArg2, TArg3, AsyncCallback, Object, IAsyncResult>)>)
The delegate that begins the asynchronous operation.
endMethod
Type: System..::.Func<(Of <(IAsyncResult, TResult >)>)
The delegate that ends the asynchronous operation.
arg1
Type: TArg1
The first argument passed to the beginMethod delegate.
arg2
Type: TArg2
The second argument passed to the beginMethod delegate.
arg3
Type: TArg3
The third argument passed to the beginMethod delegate.
state
Type: System..::.Object
An object containing data to be used by the beginMethod delegate.

Type Parameters

TArg1
The type of the first argument passed to the beginMethod delegate.
TArg2
The type of the second argument passed to beginMethod delegate.
TArg3
The type of the third argument passed to beginMethod delegate.

Return Value

The created Task that represents the asynchronous operation.

Remarks

This method throws any exceptions thrown by the beginMethod.

Exceptions

Exception | Condition
System..::.ArgumentNullException | The exception that is thrown when the beginMethod argument is null.
System..::.ArgumentNullException | The exception that is thrown when the endMethod argument is null.

See Also

TaskFactory<(Of <(TResult>)>) Class
FromAsync Overload
System.Threading.Tasks Namespace


FromAsync(TArg1, TArg2) Method (Func(TArg1, TArg2, AsyncCallback, Object, IAsyncResult), Func(IAsyncResult, TResult), TArg1, TArg2, Object, TaskCreationOptions)

[image]

.NET Framework Class Library
TaskFactory<(Of <(TResult>)>)..::.FromAsync<(Of <(TArg1, TArg2>)>) Method (Func<(Of <(TArg1, TArg2, AsyncCallback, Object, IAsyncResult>)>), Func<(Of <(IAsyncResult, TResult>)>), TArg1, TArg2, Object, TaskCreationOptions)
TaskFactory<(Of <(TResult>)>) Class See Also Send Feedback

Creates a Task that represents a pair of begin and end methods that conform to the Asynchronous Programming Model pattern.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Function FromAsync(Of TArg1, TArg2) ( _
    beginMethod As Func(Of TArg1, TArg2, AsyncCallback, Object, IAsyncResult), _
    endMethod As Func(Of IAsyncResult, TResult), _
    arg1 As TArg1, _
    arg2 As TArg2, _
    state As Object, _
    creationOptions As TaskCreationOptions _
) As Task(Of TResult)
C#
public Task<TResult> FromAsync<TArg1, TArg2>(
    Func<TArg1, TArg2, AsyncCallback, Object, IAsyncResult> beginMethod,
    Func<IAsyncResult, TResult> endMethod,
    TArg1 arg1,
    TArg2 arg2,
    Object state,
    TaskCreationOptions creationOptions
)

Parameters

beginMethod
Type: System..::.Func<(Of <(TArg1, TArg2, AsyncCallback, Object, IAsyncResult>)>)
The delegate that begins the asynchronous operation.
endMethod
Type: System..::.Func<(Of <(IAsyncResult, TResult >)>)
The delegate that ends the asynchronous operation.
arg1
Type: TArg1
The first argument passed to the beginMethod delegate.
arg2
Type: TArg2
The second argument passed to the beginMethod delegate.
state
Type: System..::.Object
An object containing data to be used by the beginMethod delegate.
creationOptions
Type: System.Threading.Tasks..::.TaskCreationOptions
The TaskCreationOptions value that controls the behavior of the created Task.

Type Parameters

TArg1
The type of the first argument passed to the beginMethod delegate.
TArg2
The type of the second argument passed to beginMethod delegate.

Return Value

The created Task that represents the asynchronous operation.

Remarks

This method throws any exceptions thrown by the beginMethod.

Exceptions

Exception | Condition
System..::.ArgumentNullException | The exception that is thrown when the beginMethod argument is null.
System..::.ArgumentNullException | The exception that is thrown when the endMethod argument is null.
System..::.ArgumentOutOfRangeException | The exception that is thrown when the creationOptions argument specifies an invalid TaskCreationOptions value.

See Also

TaskFactory<(Of <(TResult>)>) Class
FromAsync Overload
System.Threading.Tasks Namespace


FromAsync(TArg1, TArg2, TArg3) Method (Func_(TArg1, TArg2, TArg3, AsyncCallback, Object, IAsyncResult), Func(IAsyncResult, TResult), TArg1, TArg2, TArg3, Object, TaskCreationOptions)

[image]

.NET Framework Class Library
TaskFactory<(Of <(TResult>)>)..::.FromAsync<(Of <(TArg1, TArg2, TArg3>)>) Method (Func_<(Of <(TArg1, TArg2, TArg3, AsyncCallback, Object, IAsyncResult>)>), Func<(Of <(IAsyncResult, TResult>)>), TArg1, TArg2, TArg3, Object, TaskCreationOptions)
TaskFactory<(Of <(TResult>)>) Class See Also Send Feedback

Creates a Task that represents a pair of begin and end methods that conform to the Asynchronous Programming Model pattern.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Function FromAsync(Of TArg1, TArg2, TArg3) ( _
    beginMethod As Func_(Of TArg1, TArg2, TArg3, AsyncCallback, Object, IAsyncResult), _
    endMethod As Func(Of IAsyncResult, TResult), _
    arg1 As TArg1, _
    arg2 As TArg2, _
    arg3 As TArg3, _
    state As Object, _
    creationOptions As TaskCreationOptions _
) As Task(Of TResult)
C#
public Task<TResult> FromAsync<TArg1, TArg2, TArg3>(
    Func_<TArg1, TArg2, TArg3, AsyncCallback, Object, IAsyncResult> beginMethod,
    Func<IAsyncResult, TResult> endMethod,
    TArg1 arg1,
    TArg2 arg2,
    TArg3 arg3,
    Object state,
    TaskCreationOptions creationOptions
)

Parameters

beginMethod
Type: System..::.Func_ <(Of <(TArg1, TArg2, TArg3, AsyncCallback, Object, IAsyncResult>)>)
The delegate that begins the asynchronous operation.
endMethod
Type: System..::.Func<(Of <(IAsyncResult, TResult >)>)
The delegate that ends the asynchronous operation.
arg1
Type: TArg1
The first argument passed to the beginMethod delegate.
arg2
Type: TArg2
The second argument passed to the beginMethod delegate.
arg3
Type: TArg3
The third argument passed to the beginMethod delegate.
state
Type: System..::.Object
An object containing data to be used by the beginMethod delegate.
creationOptions
Type: System.Threading.Tasks..::.TaskCreationOptions
The TaskCreationOptions value that controls the behavior of the created Task.

Type Parameters

TArg1
The type of the first argument passed to the beginMethod delegate.
TArg2
The type of the second argument passed to beginMethod delegate.
TArg3
The type of the third argument passed to beginMethod delegate.

Return Value

The created Task that represents the asynchronous operation.

Remarks

This method throws any exceptions thrown by the beginMethod.

Exceptions

Exception | Condition
System..::.ArgumentNullException | The exception that is thrown when the beginMethod argument is null.
System..::.ArgumentNullException | The exception that is thrown when the endMethod argument is null.
System..::.ArgumentOutOfRangeException | The exception that is thrown when the creationOptions argument specifies an invalid TaskCreationOptions value.

See Also

TaskFactory<(Of <(TResult>)>) Class
FromAsync Overload
System.Threading.Tasks Namespace


StartNew Method

[image] [image]

.NET Framework Class Library
TaskFactory<(Of <(TResult>)>)..::.StartNew Method
TaskFactory<(Of <(TResult>)>) Class See Also Send Feedback

Overload List

Name | Description
StartNew(Func<(Of <(TResult>)>)) | Creates and starts a Task<(Of <(TResult>)>).
StartNew(Func<(Of <(TResult>)>), CancellationToken) | Creates and starts a Task<(Of <(TResult>)>).
StartNew(Func<(Of <(TResult>)>), TaskCreationOptions) | Creates and starts a Task<(Of <(TResult>)>).
StartNew(Func<(Of <(Object, TResult>)>), Object) | Creates and starts a Task<(Of <(TResult>)>).
StartNew(Func<(Of <(Object, TResult>)>), Object, CancellationToken) | Creates and starts a Task<(Of <(TResult>)>).
StartNew(Func<(Of <(Object, TResult>)>), Object, TaskCreationOptions) | Creates and starts a Task<(Of <(TResult>)>).
StartNew(Func<(Of <(TResult>)>), CancellationToken, TaskCreationOptions, TaskScheduler) | Creates and starts a Task<(Of <(TResult>)>).
StartNew(Func<(Of <(Object, TResult>)>), Object, CancellationToken, TaskCreationOptions, TaskScheduler) | Creates and starts a Task<(Of <(TResult>)>).

See Also

TaskFactory<(Of <(TResult>)>) Class
System.Threading.Tasks Namespace


StartNew Method (Func(TResult))

[image]

.NET Framework Class Library
TaskFactory<(Of <(TResult>)>)..::.StartNew Method (Func<(Of <(TResult>)>))
TaskFactory<(Of <(TResult>)>) Class See Also Send Feedback

Creates and starts a Task<(Of <(TResult>)>).

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Function StartNew ( _
    function As Func(Of TResult) _
) As Task(Of TResult)
C#
public Task<TResult> StartNew(
    Func<TResult> function
)

Parameters

function
Type: System..::.Func<(Of <( TResult >)>)
A function delegate that returns the future result to be available through the Task<(Of <(TResult>)>).

Return Value

The started Task<(Of <(TResult>)>).

Remarks

Calling StartNew is functionally equivalent to creating a Task<(Of <(TResult>)>) using one of its constructors and then calling Start to schedule it for execution. However, unless creation and scheduling must be separated, StartNew is the recommended approach for both simplicity and performance.

Exceptions

Exception | Condition
System..::.ArgumentNullException | The exception that is thrown when the function argument is null.

See Also

TaskFactory<(Of <(TResult>)>) Class
StartNew Overload
System.Threading.Tasks Namespace


StartNew Method (Func(TResult), CancellationToken)

[image]

.NET Framework Class Library
TaskFactory<(Of <(TResult>)>)..::.StartNew Method (Func<(Of <(TResult>)>), CancellationToken)
TaskFactory<(Of <(TResult>)>) Class See Also Send Feedback

Creates and starts a Task<(Of <(TResult>)>).

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Function StartNew ( _
    function As Func(Of TResult), _
    cancellationToken As CancellationToken _
) As Task(Of TResult)
C#
public Task<TResult> StartNew(
    Func<TResult> function,
    CancellationToken cancellationToken
)

Parameters

function
Type: System..::.Func<(Of <( TResult >)>)
A function delegate that returns the future result to be available through the Task<(Of <(TResult>)>).
cancellationToken
Type: System.Threading..::.CancellationToken
The CancellationToken that will be assigned to the new task.

Return Value

The started Task<(Of <(TResult>)>).

Remarks

Calling StartNew is functionally equivalent to creating a Task<(Of <(TResult>)>) using one of its constructors and then calling Start to schedule it for execution. However, unless creation and scheduling must be separated, StartNew is the recommended approach for both simplicity and performance.

Exceptions

Exception | Condition
System..::.ArgumentNullException | The exception that is thrown when the function argument is null.
System..::.ObjectDisposedException | The provided CancellationToken has already been disposed.

See Also

TaskFactory<(Of <(TResult>)>) Class
StartNew Overload
System.Threading.Tasks Namespace


StartNew Method (Func(TResult), TaskCreationOptions)

[image]

.NET Framework Class Library
TaskFactory<(Of <(TResult>)>)..::.StartNew Method (Func<(Of <(TResult>)>), TaskCreationOptions)
TaskFactory<(Of <(TResult>)>) Class See Also Send Feedback

Creates and starts a Task<(Of <(TResult>)>).

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Function StartNew ( _
    function As Func(Of TResult), _
    creationOptions As TaskCreationOptions _
) As Task(Of TResult)
C#
public Task<TResult> StartNew(
    Func<TResult> function,
    TaskCreationOptions creationOptions
)

Parameters

function
Type: System..::.Func<(Of <( TResult >)>)
A function delegate that returns the future result to be available through the Task<(Of <(TResult>)>).
creationOptions
Type: System.Threading.Tasks..::.TaskCreationOptions
A TaskCreationOptions value that controls the behavior of the created Task<(Of <(TResult>)>).

Return Value

The started Task<(Of <(TResult>)>).

Remarks

Calling StartNew is functionally equivalent to creating a Task<(Of <(TResult>)>) using one of its constructors and then calling Start to schedule it for execution. However, unless creation and scheduling must be separated, StartNew is the recommended approach for both simplicity and performance.

Exceptions

Exception | Condition
System..::.ArgumentNullException | The exception that is thrown when the function argument is null.
System..::.ArgumentOutOfRangeException | The exception that is thrown when the creationOptions argument specifies an invalid TaskCreationOptions value.

See Also

TaskFactory<(Of <(TResult>)>) Class
StartNew Overload
System.Threading.Tasks Namespace


StartNew Method (Func(Object, TResult), Object)

[image]

.NET Framework Class Library
TaskFactory<(Of <(TResult>)>)..::.StartNew Method (Func<(Of <(Object, TResult>)>), Object)
TaskFactory<(Of <(TResult>)>) Class See Also Send Feedback

Creates and starts a Task<(Of <(TResult>)>).

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Function StartNew ( _
    function As Func(Of Object, TResult), _
    state As Object _
) As Task(Of TResult)
C#
public Task<TResult> StartNew(
    Func<Object, TResult> function,
    Object state
)

Parameters

function
Type: System..::.Func<(Of <(Object, TResult >)>)
A function delegate that returns the future result to be available through the Task<(Of <(TResult>)>).
state
Type: System..::.Object
An object containing data to be used by the function delegate.

Return Value

The started Task<(Of <(TResult>)>).

Remarks

Calling StartNew is functionally equivalent to creating a Task<(Of <(TResult>)>) using one of its constructors and then calling Start to schedule it for execution. However, unless creation and scheduling must be separated, StartNew is the recommended approach for both simplicity and performance.

Exceptions

Exception | Condition
System..::.ArgumentNullException | The exception that is thrown when the function argument is null.

See Also

TaskFactory<(Of <(TResult>)>) Class
StartNew Overload
System.Threading.Tasks Namespace


StartNew Method (Func(Object, TResult), Object, CancellationToken)

[image]

.NET Framework Class Library
TaskFactory<(Of <(TResult>)>)..::.StartNew Method (Func<(Of <(Object, TResult>)>), Object, CancellationToken)
TaskFactory<(Of <(TResult>)>) Class See Also Send Feedback

Creates and starts a Task<(Of <(TResult>)>).

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Function StartNew ( _
    function As Func(Of Object, TResult), _
    state As Object, _
    cancellationToken As CancellationToken _
) As Task(Of TResult)
C#
public Task<TResult> StartNew(
    Func<Object, TResult> function,
    Object state,
    CancellationToken cancellationToken
)

Parameters

function
Type: System..::.Func<(Of <(Object, TResult >)>)
A function delegate that returns the future result to be available through the Task<(Of <(TResult>)>).
state
Type: System..::.Object
An object containing data to be used by the function delegate.
cancellationToken
Type: System.Threading..::.CancellationToken
The CancellationToken that will be assigned to the new task.

Return Value

The started Task<(Of <(TResult>)>).

Remarks

Calling StartNew is functionally equivalent to creating a Task<(Of <(TResult>)>) using one of its constructors and then calling Start to schedule it for execution. However, unless creation and scheduling must be separated, StartNew is the recommended approach for both simplicity and performance.

Exceptions

Exception | Condition
System..::.ArgumentNullException | The exception that is thrown when the function argument is null.
System..::.ObjectDisposedException | The provided CancellationToken has already been disposed.

See Also

TaskFactory<(Of <(TResult>)>) Class
StartNew Overload
System.Threading.Tasks Namespace


StartNew Method (Func(Object, TResult), Object, TaskCreationOptions)

[image]

.NET Framework Class Library
TaskFactory<(Of <(TResult>)>)..::.StartNew Method (Func<(Of <(Object, TResult>)>), Object, TaskCreationOptions)
TaskFactory<(Of <(TResult>)>) Class See Also Send Feedback

Creates and starts a Task<(Of <(TResult>)>).

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Function StartNew ( _
    function As Func(Of Object, TResult), _
    state As Object, _
    creationOptions As TaskCreationOptions _
) As Task(Of TResult)
C#
public Task<TResult> StartNew(
    Func<Object, TResult> function,
    Object state,
    TaskCreationOptions creationOptions
)

Parameters

function
Type: System..::.Func<(Of <(Object, TResult >)>)
A function delegate that returns the future result to be available through the Task<(Of <(TResult>)>).
state
Type: System..::.Object
An object containing data to be used by the function delegate.
creationOptions
Type: System.Threading.Tasks..::.TaskCreationOptions
A TaskCreationOptions value that controls the behavior of the created Task<(Of <(TResult>)>).

Return Value

The started Task<(Of <(TResult>)>).

Remarks

Calling StartNew is functionally equivalent to creating a Task<(Of <(TResult>)>) using one of its constructors and then calling Start to schedule it for execution. However, unless creation and scheduling must be separated, StartNew is the recommended approach for both simplicity and performance.

Exceptions

Exception | Condition
System..::.ArgumentNullException | The exception that is thrown when the function argument is null.
System..::.ArgumentOutOfRangeException | The exception that is thrown when the creationOptions argument specifies an invalid TaskCreationOptions value.

See Also

TaskFactory<(Of <(TResult>)>) Class
StartNew Overload
System.Threading.Tasks Namespace


StartNew Method (Func(TResult), CancellationToken, TaskCreationOptions, TaskScheduler)

[image]

.NET Framework Class Library
TaskFactory<(Of <(TResult>)>)..::.StartNew Method (Func<(Of <(TResult>)>), CancellationToken, TaskCreationOptions, TaskScheduler)
TaskFactory<(Of <(TResult>)>) Class See Also Send Feedback

Creates and starts a Task<(Of <(TResult>)>).

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Function StartNew ( _
    function As Func(Of TResult), _
    cancellationToken As CancellationToken, _
    creationOptions As TaskCreationOptions, _
    scheduler As TaskScheduler _
) As Task(Of TResult)
C#
public Task<TResult> StartNew(
    Func<TResult> function,
    CancellationToken cancellationToken,
    TaskCreationOptions creationOptions,
    TaskScheduler scheduler
)

Parameters

function
Type: System..::.Func<(Of <( TResult >)>)
A function delegate that returns the future result to be available through the Task<(Of <(TResult>)>).
cancellationToken
Type: System.Threading..::.CancellationToken
The CancellationToken that will be assigned to the new task.
creationOptions
Type: System.Threading.Tasks..::.TaskCreationOptions
A TaskCreationOptions value that controls the behavior of the created Task<(Of <(TResult>)>).
scheduler
Type: System.Threading.Tasks..::.TaskScheduler
The TaskScheduler that is used to schedule the created Task{TResult}.

Return Value

The started Task<(Of <(TResult>)>).

Remarks

Calling StartNew is functionally equivalent to creating a Task<(Of <(TResult>)>) using one of its constructors and then calling Start to schedule it for execution. However, unless creation and scheduling must be separated, StartNew is the recommended approach for both simplicity and performance.

Exceptions

Exception | Condition
System..::.ArgumentNullException | The exception that is thrown when the function argument is null.
System..::.ArgumentNullException | The exception that is thrown when the scheduler argument is null.
System..::.ArgumentOutOfRangeException | The exception that is thrown when the creationOptions argument specifies an invalid TaskCreationOptions value.
System..::.ObjectDisposedException | The provided CancellationToken has already been disposed.

See Also

TaskFactory<(Of <(TResult>)>) Class
StartNew Overload
System.Threading.Tasks Namespace


StartNew Method (Func(Object, TResult), Object, CancellationToken, TaskCreationOptions, TaskScheduler)

[image]

.NET Framework Class Library
TaskFactory<(Of <(TResult>)>)..::.StartNew Method (Func<(Of <(Object, TResult>)>), Object, CancellationToken, TaskCreationOptions, TaskScheduler)
TaskFactory<(Of <(TResult>)>) Class See Also Send Feedback

Creates and starts a Task<(Of <(TResult>)>).

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Function StartNew ( _
    function As Func(Of Object, TResult), _
    state As Object, _
    cancellationToken As CancellationToken, _
    creationOptions As TaskCreationOptions, _
    scheduler As TaskScheduler _
) As Task(Of TResult)
C#
public Task<TResult> StartNew(
    Func<Object, TResult> function,
    Object state,
    CancellationToken cancellationToken,
    TaskCreationOptions creationOptions,
    TaskScheduler scheduler
)

Parameters

function
Type: System..::.Func<(Of <(Object, TResult >)>)
A function delegate that returns the future result to be available through the Task<(Of <(TResult>)>).
state
Type: System..::.Object
An object containing data to be used by the function delegate.
cancellationToken
Type: System.Threading..::.CancellationToken
The CancellationToken that will be assigned to the new task.
creationOptions
Type: System.Threading.Tasks..::.TaskCreationOptions
A TaskCreationOptions value that controls the behavior of the created Task<(Of <(TResult>)>).
scheduler
Type: System.Threading.Tasks..::.TaskScheduler
The TaskScheduler that is used to schedule the created Task{TResult}.

Return Value

The started Task<(Of <(TResult>)>).

Remarks

Calling StartNew is functionally equivalent to creating a Task<(Of <(TResult>)>) using one of its constructors and then calling Start to schedule it for execution. However, unless creation and scheduling must be separated, StartNew is the recommended approach for both simplicity and performance.

Exceptions

Exception | Condition
System..::.ArgumentNullException | The exception that is thrown when the function argument is null.
System..::.ArgumentNullException | The exception that is thrown when the scheduler argument is null.
System..::.ArgumentOutOfRangeException | The exception that is thrown when the creationOptions argument specifies an invalid TaskCreationOptions value.
System..::.ObjectDisposedException | The provided CancellationToken has already been disposed.

See Also

TaskFactory<(Of <(TResult>)>) Class
StartNew Overload
System.Threading.Tasks Namespace


TaskFactory(TResult) Properties

[image] [image]

.NET Framework Class Library
TaskFactory<(Of <(TResult>)>) Properties
TaskFactory<(Of <(TResult>)>) Class See Also Send Feedback

The TaskFactory<(Of <(TResult>)>) type exposes the following members.

Properties

Name | Description
CancellationToken | Gets the default CancellationToken of this TaskFactory.
ContinuationOptions | Gets the TaskContinuationOptions value of this TaskFactory{TResult}.
CreationOptions | Gets the TaskCreationOptions value of this TaskFactory{TResult}.
Scheduler | Gets the TaskScheduler of this TaskFactory{TResult}.

See Also

TaskFactory<(Of <(TResult>)>) Class
System.Threading.Tasks Namespace


CancellationToken Property

[image]

.NET Framework Class Library
TaskFactory<(Of <(TResult>)>)..::.CancellationToken Property
TaskFactory<(Of <(TResult>)>) Class See Also Send Feedback

Gets the default CancellationToken of this TaskFactory.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public ReadOnly Property CancellationToken As CancellationToken
C#
public CancellationToken CancellationToken { get; }

Remarks

This property returns the default CancellationToken that will be assigned to all tasks created by this factory unless another CancellationToken value is explicitly specified during the call to the factory methods.

See Also

TaskFactory<(Of <(TResult>)>) Class
System.Threading.Tasks Namespace


ContinuationOptions Property

[image]

.NET Framework Class Library
TaskFactory<(Of <(TResult>)>)..::.ContinuationOptions Property
TaskFactory<(Of <(TResult>)>) Class See Also Send Feedback

Gets the TaskContinuationOptions value of this TaskFactory{TResult}.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public ReadOnly Property ContinuationOptions As TaskContinuationOptions
C#
public TaskContinuationOptions ContinuationOptions { get; }

Remarks

This property returns the default continuation options for this factory. They will be used to create all continuation tasks unless other options are explicitly specified during calls to this factory's methods.

See Also

TaskFactory<(Of <(TResult>)>) Class
System.Threading.Tasks Namespace


CreationOptions Property

[image]

.NET Framework Class Library
TaskFactory<(Of <(TResult>)>)..::.CreationOptions Property
TaskFactory<(Of <(TResult>)>) Class See Also Send Feedback

Gets the TaskCreationOptions value of this TaskFactory{TResult}.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public ReadOnly Property CreationOptions As TaskCreationOptions
C#
public TaskCreationOptions CreationOptions { get; }

Remarks

This property returns the default creation options for this factory. They will be used to create all tasks unless other options are explicitly specified during calls to this factory's methods.

See Also

TaskFactory<(Of <(TResult>)>) Class
System.Threading.Tasks Namespace


Scheduler Property

[image]

.NET Framework Class Library
TaskFactory<(Of <(TResult>)>)..::.Scheduler Property
TaskFactory<(Of <(TResult>)>) Class See Also Send Feedback

Gets the TaskScheduler of this TaskFactory{TResult}.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public ReadOnly Property Scheduler As TaskScheduler
C#
public TaskScheduler Scheduler { get; }

Remarks

This property returns the default scheduler for this factory. It will be used to schedule all tasks unless another scheduler is explicitly specified during calls to this factory's methods. If null, TaskScheduler.Current will be used.

See Also

TaskFactory<(Of <(TResult>)>) Class
System.Threading.Tasks Namespace


TaskScheduler Class

[image]

.NET Framework Class Library
TaskScheduler Class
See Also Send Feedback

Represents an abstract scheduler for tasks.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
<PermissionSetAttribute(SecurityAction.InheritanceDemand, Unrestricted := True)> _
<HostProtectionAttribute(SecurityAction.LinkDemand, Synchronization := True,  _
    ExternalThreading := True)> _
Public MustInherit Class TaskScheduler
C#
[PermissionSetAttribute(SecurityAction.InheritanceDemand, Unrestricted = true)]
[HostProtectionAttribute(SecurityAction.LinkDemand, Synchronization = true,
    ExternalThreading = true)]
public abstract class TaskScheduler

Remarks

TaskScheduler acts as the extension point for all pluggable scheduling logic. This includes mechanisms such as how to schedule a task for execution, and how scheduled tasks should be exposed to debuggers.

All members of the abstract TaskScheduler type are thread-safe and may be used from multiple threads concurrently.

Inheritance Hierarchy

System..::.Object
System.Threading.Tasks..::.TaskScheduler

See Also

System.Threading.Tasks Namespace


TaskScheduler Constructor

[image]

.NET Framework Class Library
TaskScheduler Constructor
TaskScheduler Class See Also Send Feedback

Initializes the TaskScheduler.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Protected Sub New
C#
protected TaskScheduler()

See Also

TaskScheduler Class
System.Threading.Tasks Namespace


TaskScheduler Methods

[image] [image]

.NET Framework Class Library
TaskScheduler Methods
TaskScheduler Class See Also Send Feedback

The TaskScheduler type exposes the following members.

Methods

Name | Description
Equals | (Inherited from Object.)
Finalize | Frees all resources associated with this scheduler. (Overrides Object..::.Finalize()()().)
FromCurrentSynchronizationContext | Creates a TaskScheduler associated with the current SynchronizationContext.
GetHashCode | (Inherited from Object.)
GetScheduledTasks | Generates an enumerable of Task instances currently queued to the scheduler waiting to be executed.
GetType | (Inherited from Object.)
MemberwiseClone | (Inherited from Object.)
QueueTask | Queues a Task to the scheduler.
ToString | (Inherited from Object.)
TryDequeue | Attempts to dequeue a Task that was previously queued to this scheduler.
TryExecuteTask | Attempts to execute the provided Task on this scheduler.
TryExecuteTaskInline | Determines whether the provided Task can be executed synchronously in this call, and if it can, executes it.

See Also

TaskScheduler Class
System.Threading.Tasks Namespace


Finalize Method

[image]

.NET Framework Class Library
TaskScheduler..::.Finalize Method
TaskScheduler Class See Also Send Feedback

Frees all resources associated with this scheduler.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Protected Overrides Sub Finalize
C#
protected override void Finalize()

See Also

TaskScheduler Class
System.Threading.Tasks Namespace


FromCurrentSynchronizationContext Method

[image]

.NET Framework Class Library
TaskScheduler..::.FromCurrentSynchronizationContext Method
TaskScheduler Class See Also Send Feedback

Creates a TaskScheduler associated with the current SynchronizationContext.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function FromCurrentSynchronizationContext As TaskScheduler
C#
public static TaskScheduler FromCurrentSynchronizationContext()

Return Value

A TaskScheduler associated with the current SynchronizationContext, as determined by SynchronizationContext.Current.

Remarks

All Task instances queued to the returned scheduler will be executed through a call to the Post method on that context.

Exceptions

Exception | Condition
System..::.InvalidOperationException | The current SynchronizationContext may not be used as a TaskScheduler.

See Also

TaskScheduler Class
System.Threading.Tasks Namespace


GetScheduledTasks Method

[image]

.NET Framework Class Library
TaskScheduler..::.GetScheduledTasks Method
TaskScheduler Class See Also Send Feedback

Generates an enumerable of Task instances currently queued to the scheduler waiting to be executed.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Protected MustOverride Function GetScheduledTasks As IEnumerable(Of Task)
C#
protected abstract IEnumerable<Task> GetScheduledTasks()

Return Value

An enumerable that allows traversal of tasks currently queued to this scheduler.

Remarks

A class derived from TaskScheduler implements this method in order to support integration with debuggers. This method will only be invoked by the .NET Framework when the debugger requests access to the data. The enumerable returned will be traversed by debugging utilities to access the tasks currently queued to this scheduler, enabling the debugger to provide a representation of this information in the user interface.

It is important to note that, when this method is called, all other threads in the process will be frozen. Therefore, it's important to avoid synchronization with other threads that may lead to blocking. If synchronization is necessary, the method should prefer to throw a NotSupportedException than to block, which could cause a debugger to experience delays. Additionally, this method and the enumerable returned must not modify any globally visible state.

The returned enumerable should never be null. If there are currently no queued tasks, an empty enumerable should be returned instead.

For developers implementing a custom debugger, this method shouldn't be called directly, but rather this functionality should be accessed through the internal wrapper method GetScheduledTasksForDebugger: internal Task[] GetScheduledTasksForDebugger(). This method returns an array of tasks, rather than an enumerable. In order to retrieve a list of active schedulers, a debugger may use another internal method: internal static TaskScheduler[] GetTaskSchedulersForDebugger(). This static method returns an array of all active TaskScheduler instances. GetScheduledTasksForDebugger then may be used on each of these scheduler instances to retrieve the list of scheduled tasks for each.

Exceptions

Exception | Condition
System..::.NotSupportedException | This scheduler is unable to generate a list of queued tasks at this time.

See Also

TaskScheduler Class
System.Threading.Tasks Namespace


QueueTask Method

[image]

.NET Framework Class Library
TaskScheduler..::.QueueTask Method
TaskScheduler Class See Also Send Feedback

Queues a Task to the scheduler.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Protected Friend MustOverride Sub QueueTask ( _
    task As Task _
)
C#
protected internal abstract void QueueTask(
    Task task
)

Parameters

task
Type: System.Threading.Tasks..::.Task
The Task to be queued.

Remarks

A class derived from TaskScheduler implements this method to accept tasks being scheduled on the scheduler. A typical implementation would store the task in an internal data structure, which would be serviced by threads that would execute those tasks at some time in the future.

This method is only meant to be called by the .NET Framework and should not be called directly by the derived class. This is necessary for maintaining the consistency of the system.

Exceptions

Exception | Condition
System..::.ArgumentNullException | The task argument is null.

See Also

TaskScheduler Class
System.Threading.Tasks Namespace


TryDequeue Method

[image]

.NET Framework Class Library
TaskScheduler..::.TryDequeue Method
TaskScheduler Class See Also Send Feedback

Attempts to dequeue a Task that was previously queued to this scheduler.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Protected Friend Overridable Function TryDequeue ( _
    task As Task _
) As Boolean
C#
protected internal virtual bool TryDequeue(
    Task task
)

Parameters

task
Type: System.Threading.Tasks..::.Task
The Task to be dequeued.

Return Value

A Boolean denoting whether the task argument was successfully dequeued.

Exceptions

Exception | Condition
System..::.ArgumentNullException | The task argument is null.

See Also

TaskScheduler Class
System.Threading.Tasks Namespace


TryExecuteTask Method

[image]

.NET Framework Class Library
TaskScheduler..::.TryExecuteTask Method
TaskScheduler Class See Also Send Feedback

Attempts to execute the provided Task on this scheduler.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Protected Function TryExecuteTask ( _
    task As Task _
) As Boolean
C#
protected bool TryExecuteTask(
    Task task
)

Parameters

task
Type: System.Threading.Tasks..::.Task
A Task object to be executed.

Return Value

A Boolean that is true if task was successfully executed, false if it was not. A common reason for execution failure is that the task had previously been executed or is in the process of being executed by another thread.

Remarks

Scheduler implementations are provided with Task instances to be executed through either the QueueTask(Task) method or the TryExecuteTaskInline(Task, Boolean) method. When the scheduler deems it appropriate to run the provided task, TryExecuteTask(Task) should be used to do so. TryExecuteTask handles all aspects of executing a task, including action invocation, exception handling, state management, and lifecycle control.

TryExecuteTask(Task) must only be used for tasks provided to this scheduler by the .NET Framework infrastructure. It should not be used to execute arbitrary tasks obtained through custom mechanisms.

Exceptions

Exception | Condition
System..::.InvalidOperationException | The task is not associated with this scheduler.

See Also

TaskScheduler Class
System.Threading.Tasks Namespace


TryExecuteTaskInline Method

[image]

.NET Framework Class Library
TaskScheduler..::.TryExecuteTaskInline Method
TaskScheduler Class See Also Send Feedback

Determines whether the provided Task can be executed synchronously in this call, and if it can, executes it.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Protected MustOverride Function TryExecuteTaskInline ( _
    task As Task, _
    taskWasPreviouslyQueued As Boolean _
) As Boolean
C#
protected abstract bool TryExecuteTaskInline(
    Task task,
    bool taskWasPreviouslyQueued
)

Parameters

task
Type: System.Threading.Tasks..::.Task
The Task to be executed.
taskWasPreviouslyQueued
Type: System..::.Boolean
A Boolean denoting whether or not task has previously been queued. If this parameter is True, then the task may have been previously queued (scheduled); if False, then the task is known not to have been queued, and this call is being made in order to execute the task inline without queueing it.

Return Value

A Boolean value indicating whether the task was executed inline.

Remarks

A class derived from TaskScheduler implements this function to support inline execution of a task on a thread that initiates a wait on that task object. Inline execution is optional, and the request may be rejected by returning false. However, better scalability typically results the more tasks that can be inlined, and in fact a scheduler that inlines too little may be prone to deadlocks. A proper implementation should ensure that a request executing under the policies guaranteed by the scheduler can successfully inline. For example, if a scheduler uses a dedicated thread to execute tasks, any inlining requests from that thread should succeed.

If a scheduler decides to perform the inline execution, it should do so by calling to the base TaskScheduler's TryExecuteTask method with the provided task object, propagating the return value. It may also be appropriate for the scheduler to remove an inlined task from its internal data structures if it decides to honor the inlining request. Note, however, that under some circumstances a scheduler may be asked to inline a task that was not previously provided to it with the QueueTask(Task) method.

The derived scheduler is responsible for making sure that the calling thread is suitable for executing the given task as far as its own scheduling and execution policies are concerned.

Exceptions

Exception | Condition
System..::.ArgumentNullException | The task argument is null.
System..::.InvalidOperationException | The task was already executed.

See Also

TaskScheduler Class
System.Threading.Tasks Namespace


TaskScheduler Properties

[image] [image]

.NET Framework Class Library
TaskScheduler Properties
TaskScheduler Class See Also Send Feedback

The TaskScheduler type exposes the following members.

Properties

Name | Description
Current | Gets the TaskScheduler associated with the currently executing task.
Default | Gets the default TaskScheduler instance.
Id | Gets the unique ID for this TaskScheduler.
MaximumConcurrencyLevel | Indicates the maximum concurrency level this TaskScheduler is able to support.

See Also

TaskScheduler Class
System.Threading.Tasks Namespace


Current Property

[image]

.NET Framework Class Library
TaskScheduler..::.Current Property
TaskScheduler Class See Also Send Feedback

Gets the TaskScheduler associated with the currently executing task.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared ReadOnly Property Current As TaskScheduler
C#
public static TaskScheduler Current { get; }

Remarks

When not called from within a task, Current will return the Default scheduler.

See Also

TaskScheduler Class
System.Threading.Tasks Namespace


Default Property

[image]

.NET Framework Class Library
TaskScheduler..::.Default Property
TaskScheduler Class See Also Send Feedback

Gets the default TaskScheduler instance.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared ReadOnly Property Default As TaskScheduler
C#
public static TaskScheduler Default { get; }

See Also

TaskScheduler Class
System.Threading.Tasks Namespace


Id Property

[image]

.NET Framework Class Library
TaskScheduler..::.Id Property
TaskScheduler Class See Also Send Feedback

Gets the unique ID for this TaskScheduler.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public ReadOnly Property Id As Integer
C#
public int Id { get; }

See Also

TaskScheduler Class
System.Threading.Tasks Namespace


MaximumConcurrencyLevel Property

[image]

.NET Framework Class Library
TaskScheduler..::.MaximumConcurrencyLevel Property
TaskScheduler Class See Also Send Feedback

Indicates the maximum concurrency level this TaskScheduler is able to support.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Overridable ReadOnly Property MaximumConcurrencyLevel As Integer
C#
public virtual int MaximumConcurrencyLevel { get; }

See Also

TaskScheduler Class
System.Threading.Tasks Namespace


TaskScheduler Events

[image] [image]

.NET Framework Class Library
TaskScheduler Events
TaskScheduler Class See Also Send Feedback

The TaskScheduler type exposes the following members.

Events

Name | Description
UnobservedTaskException | Occurs when a faulted Task's unobserved exception is about to trigger exception escalation policy, which, by default, would terminate the process.

See Also

TaskScheduler Class
System.Threading.Tasks Namespace


UnobservedTaskException Event

[image]

.NET Framework Class Library
TaskScheduler..::.UnobservedTaskException Event
TaskScheduler Class See Also Send Feedback

Occurs when a faulted Task's unobserved exception is about to trigger exception escalation policy, which, by default, would terminate the process.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Event UnobservedTaskException As EventHandler(Of UnobservedTaskExceptionEventArgs)
C#
public static event EventHandler<UnobservedTaskExceptionEventArgs> UnobservedTaskException

Remarks

This AppDomain-wide event provides a mechanism to prevent exception escalation policy (which, by default, terminates the process) from triggering. Each handler is passed a UnobservedTaskExceptionEventArgs instance, which may be used to examine the exception and to mark it as observed.

See Also

TaskScheduler Class
System.Threading.Tasks Namespace


TaskSchedulerException Class

[image]

.NET Framework Class Library
TaskSchedulerException Class
See Also Send Feedback

Represents an exception used to communicate an invalid operation by a TaskScheduler.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
<SerializableAttribute> _
Public Class TaskSchedulerException _
    Inherits Exception
C#
[SerializableAttribute]
public class TaskSchedulerException : Exception

Inheritance Hierarchy

System..::.Object
System..::.Exception
System.Threading.Tasks..::.TaskSchedulerException

See Also

System.Threading.Tasks Namespace


TaskSchedulerException Constructor

[image] [image]

.NET Framework Class Library
TaskSchedulerException Constructor
TaskSchedulerException Class See Also Send Feedback

Overload List

Name | Description
TaskSchedulerException()()() | Initializes a new instance of the TaskSchedulerException class.
TaskSchedulerException(Exception) | Initializes a new instance of the TaskSchedulerException class using the default error message and a reference to the inner exception that is the cause of this exception.
TaskSchedulerException(String) | Initializes a new instance of the TaskSchedulerException class with a specified error message.
TaskSchedulerException(SerializationInfo, StreamingContext) | Initializes a new instance of the TaskSchedulerException class with serialized data.
TaskSchedulerException(String, Exception) | Initializes a new instance of the TaskSchedulerException class with a specified error message and a reference to the inner exception that is the cause of this exception.

See Also

TaskSchedulerException Class
System.Threading.Tasks Namespace


TaskSchedulerException Constructor

[image]

.NET Framework Class Library
TaskSchedulerException Constructor
TaskSchedulerException Class See Also Send Feedback

Initializes a new instance of the TaskSchedulerException class.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Sub New
C#
public TaskSchedulerException()

See Also

TaskSchedulerException Class
TaskSchedulerException Overload
System.Threading.Tasks Namespace


TaskSchedulerException Constructor (Exception)

[image]

.NET Framework Class Library
TaskSchedulerException Constructor (Exception)
TaskSchedulerException Class See Also Send Feedback

Initializes a new instance of the TaskSchedulerException class using the default error message and a reference to the inner exception that is the cause of this exception.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Sub New ( _
    innerException As Exception _
)
C#
public TaskSchedulerException(
    Exception innerException
)

Parameters

innerException
Type: System..::.Exception
The exception that is the cause of the current exception.

See Also

TaskSchedulerException Class
TaskSchedulerException Overload
System.Threading.Tasks Namespace


TaskSchedulerException Constructor (String)

[image]

.NET Framework Class Library
TaskSchedulerException Constructor (String)
TaskSchedulerException Class See Also Send Feedback

Initializes a new instance of the TaskSchedulerException class with a specified error message.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Sub New ( _
    message As String _
)
C#
public TaskSchedulerException(
    string message
)

Parameters

message
Type: System..::.String
The error message that explains the reason for the exception.

See Also

TaskSchedulerException Class
TaskSchedulerException Overload
System.Threading.Tasks Namespace


TaskSchedulerException Constructor (SerializationInfo, StreamingContext)

[image]

.NET Framework Class Library
TaskSchedulerException Constructor (SerializationInfo, StreamingContext)
TaskSchedulerException Class See Also Send Feedback

Initializes a new instance of the TaskSchedulerException class with serialized data.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Protected Sub New ( _
    info As SerializationInfo, _
    context As StreamingContext _
)
C#
protected TaskSchedulerException(
    SerializationInfo info,
    StreamingContext context
)

Parameters

info
Type: System.Runtime.Serialization..::.SerializationInfo
The SerializationInfo that holds the serialized object data about the exception being thrown.
context
Type: System.Runtime.Serialization..::.StreamingContext
The StreamingContext that contains contextual information about the source or destination.

See Also

TaskSchedulerException Class
TaskSchedulerException Overload
System.Threading.Tasks Namespace


TaskSchedulerException Constructor (String, Exception)

[image]

.NET Framework Class Library
TaskSchedulerException Constructor (String, Exception)
TaskSchedulerException Class See Also Send Feedback

Initializes a new instance of the TaskSchedulerException class with a specified error message and a reference to the inner exception that is the cause of this exception.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Sub New ( _
    message As String, _
    innerException As Exception _
)
C#
public TaskSchedulerException(
    string message,
    Exception innerException
)

Parameters

message
Type: System..::.String
The error message that explains the reason for the exception.
innerException
Type: System..::.Exception
The exception that is the cause of the current exception.

See Also

TaskSchedulerException Class
TaskSchedulerException Overload
System.Threading.Tasks Namespace


TaskSchedulerException Methods

[image] [image]

.NET Framework Class Library
TaskSchedulerException Methods
TaskSchedulerException Class See Also Send Feedback

The TaskSchedulerException type exposes the following members.

Methods

Name | Description
Equals | (Inherited from Object.)
Finalize | (Inherited from Object.)
GetBaseException | (Inherited from Exception.)
GetHashCode | (Inherited from Object.)
GetObjectData | (Inherited from Exception.)
GetType | (Inherited from Exception.)
MemberwiseClone | (Inherited from Object.)
ToString | (Inherited from Exception.)

See Also

TaskSchedulerException Class
System.Threading.Tasks Namespace


TaskSchedulerException Properties

[image] [image]

.NET Framework Class Library
TaskSchedulerException Properties
TaskSchedulerException Class See Also Send Feedback

The TaskSchedulerException type exposes the following members.

Properties

Name | Description
Data | (Inherited from Exception.)
HelpLink | (Inherited from Exception.)
HResult | (Inherited from Exception.)
InnerException | (Inherited from Exception.)
Message | (Inherited from Exception.)
Source | (Inherited from Exception.)
StackTrace | (Inherited from Exception.)
TargetSite | (Inherited from Exception.)

See Also

TaskSchedulerException Class
System.Threading.Tasks Namespace


TaskStatus Enumeration

[image]

.NET Framework Class Library
TaskStatus Enumeration
See Also Send Feedback

Represents the current stage in the lifecycle of a Task.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Enumeration TaskStatus
C#
public enum TaskStatus

Members

Member name | Description
Created | The task has been initialized but has not yet been scheduled.
WaitingForActivation | The task is waiting to be activated and scheduled internally by the .NET Framework infrastructure.
WaitingToRun | The task has been scheduled for execution but has not yet begun executing.
Running | The task is running but has not yet completed.
WaitingForChildrenToComplete | The task has finished executing and is implicitly waiting for attached child tasks to complete.
RanToCompletion | The task completed execution successfully.
Canceled | The task acknowledged cancellation by throwing an OperationCanceledException with its own CancellationToken while the token was in signaled state, or the task's CancellationToken was already signaled before the task started executing.
Faulted | The task completed due to an unhandled exception.

See Also

System.Threading.Tasks Namespace


UnobservedTaskExceptionEventArgs Class

[image]

.NET Framework Class Library
UnobservedTaskExceptionEventArgs Class
See Also Send Feedback

Provides data for the event that is raised when a faulted Task's exception goes unobserved.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Class UnobservedTaskExceptionEventArgs _
    Inherits EventArgs
C#
public class UnobservedTaskExceptionEventArgs : EventArgs

Remarks

The Exception property is used to examine the exception without marking it as observed, whereas the SetObserved()()() method is used to mark the exception as observed. Marking the exception as observed prevents it from triggering exception escalation policy which, by default, terminates the process.

Inheritance Hierarchy

System..::.Object
System..::.EventArgs
System.Threading.Tasks..::.UnobservedTaskExceptionEventArgs

See Also

System.Threading.Tasks Namespace


UnobservedTaskExceptionEventArgs Constructor

[image]

.NET Framework Class Library
UnobservedTaskExceptionEventArgs Constructor
UnobservedTaskExceptionEventArgs Class See Also Send Feedback

Initializes a new instance of the UnobservedTaskExceptionEventArgs class with the unobserved exception.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Sub New ( _
    exception As AggregateException _
)
C#
public UnobservedTaskExceptionEventArgs(
    AggregateException exception
)

Parameters

exception
Type: System..::.AggregateException
The Exception that has gone unobserved.

See Also

UnobservedTaskExceptionEventArgs Class
System.Threading.Tasks Namespace


UnobservedTaskExceptionEventArgs Methods

[image] [image]

.NET Framework Class Library
UnobservedTaskExceptionEventArgs Methods
UnobservedTaskExceptionEventArgs Class See Also Send Feedback

The UnobservedTaskExceptionEventArgs type exposes the following members.

Methods

Name | Description
Equals | (Inherited from Object.)
Finalize | (Inherited from Object.)
GetHashCode | (Inherited from Object.)
GetType | (Inherited from Object.)
MemberwiseClone | (Inherited from Object.)
SetObserved | Marks the Exception as "observed," thus preventing it from triggering exception escalation policy which, by default, terminates the process.
ToString | (Inherited from Object.)

See Also

UnobservedTaskExceptionEventArgs Class
System.Threading.Tasks Namespace


SetObserved Method

[image]

.NET Framework Class Library
UnobservedTaskExceptionEventArgs..::.SetObserved Method
UnobservedTaskExceptionEventArgs Class See Also Send Feedback

Marks the Exception as "observed," thus preventing it from triggering exception escalation policy which, by default, terminates the process.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Sub SetObserved
C#
public void SetObserved()

See Also

UnobservedTaskExceptionEventArgs Class
System.Threading.Tasks Namespace


UnobservedTaskExceptionEventArgs Properties

[image] [image]

.NET Framework Class Library
UnobservedTaskExceptionEventArgs Properties
UnobservedTaskExceptionEventArgs Class See Also Send Feedback

The UnobservedTaskExceptionEventArgs type exposes the following members.

Properties

Name | Description
Exception | The Exception that went unobserved.
Observed | Gets whether this exception has been marked as "observed."

See Also

UnobservedTaskExceptionEventArgs Class
System.Threading.Tasks Namespace


Exception Property

[image]

.NET Framework Class Library
UnobservedTaskExceptionEventArgs..::.Exception Property
UnobservedTaskExceptionEventArgs Class See Also Send Feedback

The Exception that went unobserved.

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public ReadOnly Property Exception As AggregateException
C#
public AggregateException Exception { get; }

See Also

UnobservedTaskExceptionEventArgs Class
System.Threading.Tasks Namespace


Observed Property

[image]

.NET Framework Class Library
UnobservedTaskExceptionEventArgs..::.Observed Property
UnobservedTaskExceptionEventArgs Class See Also Send Feedback

Gets whether this exception has been marked as "observed."

Namespace: System.Threading.Tasks
Assembly: System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public ReadOnly Property Observed As Boolean
C#
public bool Observed { get; }

See Also

UnobservedTaskExceptionEventArgs Class
System.Threading.Tasks Namespace