Class WorkExecutionContext
A hierarchical execution context for IComputationalWork.
Inheritance
Namespace: DNVGL.One.Compute.WorkExecution.ExecutionModel
Assembly: DNVGL.One.Compute.WorkExecution.dll
Syntax
public class WorkExecutionContext : object, IExecutionContext, IVariableContainer
Constructors
View SourceWorkExecutionContext(WorkExecutionContext, IComputationalWork, CancellationToken)
Initializes a new instance of the WorkExecutionContext class.
Declaration
public WorkExecutionContext(WorkExecutionContext parentContext, IComputationalWork work, CancellationToken cancellationToken)
Parameters
Type | Name | Description |
---|---|---|
WorkExecutionContext | parentContext | The parent context. |
IComputationalWork | work | The work. |
CancellationToken | cancellationToken | The cancellation token. |
Properties
View SourceCancellationToken
Gets the cancellation token.
Declaration
public CancellationToken CancellationToken { get; }
Property Value
Type | Description |
---|---|
CancellationToken | The cancellation token. |
Exception
Gets the exception if an exception occurred while executing the ExecutableWork.
Declaration
public Exception Exception { get; }
Property Value
Type | Description |
---|---|
Exception | The exception. |
ExecutableWork
Gets the executable work.
Declaration
public IComputationalWork ExecutableWork { get; }
Property Value
Type | Description |
---|---|
IComputationalWork | The executable work. |
Item[String]
Gets or sets the
Declaration
public object this[string variableName] { get; set; }
Parameters
Type | Name | Description |
---|---|---|
System.String | variableName | Name of the variable. |
Property Value
Type | Description |
---|---|
System.Object | The |
Message
Gets the message.
Declaration
public string Message { get; }
Property Value
Type | Description |
---|---|
System.String | The message. |
Progress
Gets the progress as a fraction between 0 (no progress) and 1 (complete).
Declaration
public double Progress { get; }
Property Value
Type | Description |
---|---|
System.Double | The progress as a fraction between 0 and 1. |
Result
Gets the result from executing the work.
Declaration
public object Result { get; }
Property Value
Type | Description |
---|---|
System.Object | The result. |
Status
Gets the work status.
Declaration
public WorkStatus Status { get; }
Property Value
Type | Description |
---|---|
WorkStatus | The status. |
Variables
Gets the context variables.
Declaration
public IEnumerable<Variable> Variables { get; }
Property Value
Type | Description |
---|---|
IEnumerable<Variable> | The context variables. |
Methods
View SourceCreateRootContext(IComputationalWork)
Creates the root context.
Declaration
public static IExecutionContext CreateRootContext(IComputationalWork work = null)
Parameters
Type | Name | Description |
---|---|---|
IComputationalWork | work | The work. |
Returns
Type | Description |
---|---|
IExecutionContext | A root IExecutionContext. |
DerivedContextUpdated(IExecutionContext)
A derived execution context was updated.
Declaration
public void DerivedContextUpdated(IExecutionContext derivedContext)
Parameters
Type | Name | Description |
---|---|---|
IExecutionContext | derivedContext | The derived context. |
IsAssigned(String, Boolean)
Determines whether this variable has been assigned.
Declaration
public bool IsAssigned(string variableName, bool searchContextHierarchy = true)
Parameters
Type | Name | Description |
---|---|---|
System.String | variableName | Name of the variable. |
System.Boolean | searchContextHierarchy | if set to |
Returns
Type | Description |
---|---|
System.Boolean |
|
Events
View SourceWorkEvent
Occurs when the status or progress of a work item changes.
Declaration
public event EventHandler<ExecutableWorkEventArgs> WorkEvent
Event Type
Type | Description |
---|---|
EventHandler<ExecutableWorkEventArgs> |
Explicit Interface Implementations
View SourceIExecutionContext.Abort(String)
Aborts the work.
Declaration
void IExecutionContext.Abort(string message)
Parameters
Type | Name | Description |
---|---|---|
System.String | message | The message. |
IExecutionContext.Complete(Object, String)
Completes the work.
Declaration
void IExecutionContext.Complete(object result, string message)
Parameters
Type | Name | Description |
---|---|---|
System.Object | result | The execution result. |
System.String | message | The message. |
IExecutionContext.Derive(IComputationalWork)
Derives a child context for a particular combination of work and input.
Declaration
IExecutionContext IExecutionContext.Derive(IComputationalWork work)
Parameters
Type | Name | Description |
---|---|---|
IComputationalWork | work | The work. |
Returns
Type | Description |
---|---|
IExecutionContext | A child context. |
Remarks
This is used when a composite IComputationalWork executes by executing each constituent part. In that case a dedicated context must be derived for each part.
IExecutionContext.Fail(String, Exception)
Report that the work failed.
Declaration
void IExecutionContext.Fail(string message, Exception e)
Parameters
Type | Name | Description |
---|---|---|
System.String | message | The message. |
Exception | e | The e. |
IExecutionContext.UpdateProgress(Double, String)
Updates the progress.
Declaration
void IExecutionContext.UpdateProgress(double progress, string message)
Parameters
Type | Name | Description |
---|---|---|
System.Double | progress | The progress. |
System.String | message | The message. |