Export (0) Print
Expand All

ParallelLoopState.Break Method

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:  mscorlib (in mscorlib.dll)

public void Break()


The Stop method was previously called. Break and Stop may not be used in combination by iterations of the same loop.

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.

.NET Framework

Supported in: 4.5.2, 4.5.1, 4.5, 4

.NET Framework Client Profile

Supported in: 4

Portable Class Library

Supported in: Portable Class Library

.NET for Windows Store apps

Supported in: Windows 8

.NET for Windows Phone apps

Supported in: Windows Phone 8.1

Windows Phone 8.1, Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

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

© 2014 Microsoft