Assembly: yWorks.yFilesSilverlight.Algorithms (in yWorks.yFilesSilverlight.Algorithms.dll) Version: 22.214.171.124
public class AbortHandler
Public Class AbortHandler
Client Code Usage:
An instance of this class can be attached to a graph using method CreateForGraph(Graph) . Using the handler's Stop()()()() and Cancel()()()() methods, it is possible to schedule requests for early termination. Algorithms can check for these requests and handle them appropriately.
- The algorithm should terminate gracefully, delivering a consistent result. Although the termination will be early, it usually will not be immediate.
The algorithm should terminate immediately, all work done so far will be
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 ILayouter 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 one 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.
Methods stop and cancel are primarily meant for multi-threaded use case scenarios where the algorithm runs in a background thread and stop/cancel are called from the main or UI thread. For pure single-threaded use cases, methods StopDuration and CancelDuration may be used to automatically stop or cancel the algorithm after a specified period of time has elapsed.
Usage in Algorithms:
Algorithms have to retrieve an instance of this class from the graph that is processed using method GetFromGraph(Graph) . The algorithm then needs to query the retrieved instance of this class for stop or cancel requests using method Check()()()() .
Alternatively, convenience method Check(Graph) 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.