documentationfor yFiles for HTML 2.6

AbortHandler

This class provides a means for early termination of graph algorithms.

Inheritance Hierarchy
AbortHandler

Remarks

Instances of this class may be attached to and retrieved from a graph and may receive requests for stopping and canceling an algorithm that is currently executed on the given graph.

Client Code Usage

An instance of this class can be attached to a graph using method createForGraph. The handler's stopDuration and cancelDuration methods can be used to automatically stop or cancel an algorithm after a specified period of time has elapsed. Algorithms can check for these requests and handle them appropriately.

  • Stop – The algorithm should terminate gracefully, delivering a consistent result. Although the termination will be early, it will usually not be immediate.
  • Cancel – The algorithm should terminate immediately and all work done so far will be discarded.

    IMPORTANT: It is not guaranteed that the processed graph will be in a consistent state after cancellation. For this reason, it is strongly recommended to cancel only algorithms that work on copies of the real graph structure such as layout algorithms running in buffered mode. Furthermore, the state of the used ILayoutAlgorithm instance may become corrupted. Hence, a new instance has to be created after each cancellation.

If a graph with an attached handler is processed by multiple algorithms (or multiple times by the same algorithm), the attached handler has to be reset between algorithm runs. Otherwise, previous requests for early termination may lead to an undesired early termination of the next algorithm run.

Usage in Algorithms

Algorithms have to retrieve an instance of this class from the graph that is processed using method getFromGraph. Then, the algorithm needs to query the retrieved instance of this class for stop or cancel requests using method check.

Alternatively, convenience method check for one-time checks is available. For performance critical code that checks repeatedly, it is recommended to follow the first approach, though.

When handling a stop request, algorithms should ensure that the resulting graph is still in a consistent state.

Default Values of Properties

cancelDurationZERONo automatic termination will occur.
stopDurationZERONo automatic termination will occur.

Type Details

yfiles module
algorithms
yfiles-umd modules
All layout modules, view-layout-bridge
Legacy UMD name
yfiles.algorithms.AbortHandler

See Also

Constructors

Properties

Methods

Constants

Static Methods