SolutionServer

References
public class SolutionServer
This class provides all methods and properties concerning past document solutions and how to start new ones.

Constructors

SolutionServer

#
public SolutionServer(Document document)
Create a new Solution instance.
document (Document)Owner document.

Fields

_triggerViewportUpdatesOnCompletedSolution

#
[EditorBrowsable(EditorBrowsableState.Never)] public static bool _triggerViewportUpdatesOnCompletedSolution

MaximumHistoryCount

#
public const int MaximumHistoryCount = 8192
Gets the maximum number of solution history records that will be kept. This field is constant and set to 10000 or thereabouts.

Properties

EnableSolutions

#
public static bool EnableSolutions { get; set; }
Gets or sets whether solutions are allowed. Setting this will neither abort nor trigger any solutions, that is the responsibility of the caller.

State

#
public ServerState State { get; }
Gets the state of this server.

Methods

DelayedExpire

#
public void DelayedExpire(IDocumentObject obj)
Call this method if you want the document to expire your object and start a new solution some time in the near future. This method is good for objects which tend to generate frequent expiration waves due to (typically) UI events such as mouse-moves or key-presses. This method does one of three things:

  1. If no solution is currently running, it expires the object immediately and starts a new solution.

2. If another solution has only just started a short while ago, it will allow that solution to continue. The object will be expired and a new solution will be started once the current solution completes.

3. If another solution is running and has been running for a while, it will be cancelled. The object will be expired and a new solution will be started immediately.

obj (IDocumentObject)Object to expire.

Start

#
public Task<Solution> Start(CancellationTokenSource source, SolutionMode mode = SolutionMode.Regular)
Start a new document solution. If another solution is currently running on the same document, that solution will be cancelled. This method returns as soon as objects are beginning to solve, ie. when the Phase is set to Running. You should use this overload if this solution runs as part of another solution on a different document. Be sure to share the Solution.Source of that containing solution, so that cancellation may be synchronised.
source (CancellationTokenSource)Optional existing cancellation source.
mode (SolutionMode = SolutionMode.Regular)Solutution mode.
Task object running the solution or a cancelled task if no solution could be started.

Start

#
public Task<Solution> Start(SolutionMode mode = SolutionMode.Regular)
Start a new document solution. If another solution is currently running, that solution will be cancelled. Although not _immediately_, this method returns as soon as objects are beginning to solve, ie. when the Phase is set to Running.
mode (SolutionMode = SolutionMode.Regular)Solutution mode.
Task object running the solution or null if there is no solution actually running.

StartWait

#
public Solution StartWait()
Start a new solution and solve it on the calling thread. You should never call this function while on the UI thread.

StartWait

#
public Solution StartWait(CancellationTokenSource source, SolutionMode mode = SolutionMode.Regular)
Start a new solution and solve it on the calling thread. You should never call this function while on the UI thread. You should use this overload if this solution runs as part of another solution on a different document. Be sure to share the Solution.Source of that containing solution, so that cancellation may be synchronised.
source (CancellationTokenSource)
mode (SolutionMode = SolutionMode.Regular)

Stop

#
public void Stop()
Attempt to abort the current solution. This happens automatically if a new solution is started. If no solution is currently running, nothing will happen.

Events

EnabledChanged

#
public static event EventHandler EnabledChanged
Raised whenever the EnableSolutions property changes. The sender and arguments are always null, given that this is a static event.

SolutionAboutToStart

#
public event EventHandler<SolutionIdEventArgs> SolutionAboutToStart
The SolutionAboutToStart event is raised before a new solution kicks off. If you want to expire objects prior to a solution, you must do so from within this event.

SolutionCancelled

#
public event EventHandler<SolutionEventArgs> SolutionCancelled
The SolutionCancelled event is raised when a solution is aborted. This event will always be followed by the SolutionStopped event.

SolutionCompleted

#
public event EventHandler<SolutionEventArgs> SolutionCompleted
The SolutionCompleted event is raised when a solution completes successfully. This event will always be followed by the SolutionStopped event.

SolutionFaulted

#
public event EventHandler<SolutionExceptionEventArgs> SolutionFaulted
The SolutionException event is raised when a solution is terminated by an unhandled exception. This event will always be followed by the SolutionCancelled and SolutionStopped events.

SolutionStarted

#
public event EventHandler<SolutionEventArgs> SolutionStarted
The SolutionStarted event is raised whenever a new solution starts.

SolutionStopped

#
public event EventHandler<SolutionEventArgs> SolutionStopped
The SolutionStopped event is raised whenever a solution terminates. Whenever there is a SolutionStarted event there will always be a matching solutionStopped event.