Stop Method

Task Parallel System.Threading

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

ExceptionCondition
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