Show / Hide Table of Contents

Class CancellableOperationBase<T>

A base class for cancelable operations over various items, supporting separate cancellation per item.

Inheritance
object
CancellableOperationBase<T>
DeviceOperationBase
OvermindAction
TestAction
Implements
ICancellableOperation<T>
IOperation<T>
ICancellableOperation
IOperation
Inherited Members
object.Equals(object)
object.Equals(object, object)
object.GetHashCode()
object.GetType()
object.MemberwiseClone()
object.ReferenceEquals(object, object)
object.ToString()
Namespace: Microsoft.XboxStudios.BotBrain.Operations
Assembly: BotBrain.Operations.dll
Syntax
public abstract class CancellableOperationBase<T> : ICancellableOperation<T>, IOperation<T>, ICancellableOperation, IOperation where T : notnull
Type Parameters
Name Description
T

The item type.

Properties

View Source

IsRunning

Gets a value indicating whether or not the operation is executing.

Declaration
public bool IsRunning { get; }
Property Value
Type Description
bool
View Source

Timeout

Gets an optional timeout.

Declaration
public TimeSpan Timeout { get; init; }
Property Value
Type Description
TimeSpan
Remarks

The operation will always timeout after the specified time, regardless of whether a cancellation token was passed or not.

Methods

View Source

Cancel(T)

Cancels an operation running on a specific item.

Declaration
public void Cancel(T item)
Parameters
Type Name Description
T item

The item.

View Source

Cancel(T, bool)

Cancels an operation running on a specific item.

Declaration
protected void Cancel(T item, bool result)
Parameters
Type Name Description
T item

The item.

bool result

The result of the operation.

View Source

ExecuteOn(T, CancellationToken)

Runs the operation on an item.

Declaration
protected abstract Task<bool> ExecuteOn(T item, CancellationToken token)
Parameters
Type Name Description
T item

The item.

CancellationToken token

A token to monitor for cancellation.

Returns
Type Description
Task<bool>

A task that returns a boolean indicating success or failure when the operation completes.

View Source

GetAwaiter(T, CancellationToken)

Gets a task used to await this operation on an item.

Declaration
public Task<bool> GetAwaiter(T item, CancellationToken token)
Parameters
Type Name Description
T item

The item to use.

CancellationToken token

A token to monitor for cancellation.

Returns
Type Description
Task<bool>

A task.

View Source

IsRunningOn(T)

Gets a value indicating whether or not the operation is executing.

Declaration
public bool IsRunningOn(T item)
Parameters
Type Name Description
T item

The item to use.

Returns
Type Description
bool

True if the operation is executing on the item.

View Source

Run(T)

Executes the operation on an item.

Declaration
public Task<bool> Run(T item)
Parameters
Type Name Description
T item

The item.

Returns
Type Description
Task<bool>

A task that returns a boolean indicating success or failure when the operation completes.

View Source

Run(T, CancellationToken)

Executes the operation on an item.

Declaration
public Task<bool> Run(T item, CancellationToken token)
Parameters
Type Name Description
T item

The item.

CancellationToken token

A token to monitor for cancellation.

Returns
Type Description
Task<bool>

A task that returns a boolean indicating success or failure when the operation completes.

View Source

TryCreateCancellationToken(T, out CancellationToken)

Attempts to create a cancellation token for an operation on the given item.

Declaration
protected bool TryCreateCancellationToken(T item, out CancellationToken token)
Parameters
Type Name Description
T item

The item.

CancellationToken token

The cancellation token.

Returns
Type Description
bool

True if a token could be created.

Events

View Source

ExecutionStateChanged

Occurs when the operation changes execution state on an item.

Declaration
public event EventHandler<OperationStateChangedInfo<T>>? ExecutionStateChanged
Event Type
Type Description
EventHandler<OperationStateChangedInfo<T>>

Implements

ICancellableOperation<T>
IOperation<T>
ICancellableOperation
IOperation

Extension Methods

IOperationExtensions.Run<T>(IOperation<T>, IEnumerable<T>)
  • View Source
In this article
Back to top Generated by DocFX