Table of Contents

Class ModuleService

Namespace
BpNexT.Actions.Abstractions
Assembly
BpNexT.Actions.Abstractions.dll

Base class for a long-running module service. Register it with services.AddHostedService<T>(); the runtime starts it when the module loads, cancels its token when the module unloads, and restarts it after a failure.

public abstract class ModuleService : IHostedService
Inheritance
object
ModuleService
Implements
Inherited Members
object.Equals(object)
object.GetHashCode()
object.ToString()

Remarks

Bp access goes through IBpSessions, which borrows a session per operation. A service runs outside action runs, so the run-scoped IBpSession is not available to it and must not be injected.

Properties

Execution

The current execution, or null before the first start. Observed by the runtime.

Logger

Logs to the runtime, tagged with the module and service id.

ModuleId

Id of the module the service belongs to.

ModuleVersion

Installed version of the module.

ServiceId

Identifies the service in logs and notifications; defaults to the type name.

Methods

ExecuteAsync(CancellationToken)

Runs until the token is cancelled. Returning early counts as an unexpected end.