Class ActivityExecutionContext
- Namespace
- Temporalio.Activities
- Assembly
- Temporalio.dll
Context that is available during activity executions. Use Current to get the context. Contexts are AsyncLocal<T> to activities. HasCurrent can be used to check whether a context is available.
public class ActivityExecutionContext
- Inheritance
-
ActivityExecutionContext
- Inherited Members
Properties
CancelReason
Gets why the activity was cancelled. This value is inaccurate until CancellationToken is cancelled.
public ActivityCancelReason CancelReason { get; }
Property Value
CancellationToken
Gets the cancellation token that is cancelled when the activity is cancelled.
public CancellationToken CancellationToken { get; }
Property Value
Current
Gets the current activity context.
public static ActivityExecutionContext Current { get; }
Property Value
Exceptions
- InvalidOperationException
If no context is available.
HasCurrent
Gets a value indicating whether the current code is running in an activity.
public static bool HasCurrent { get; }
Property Value
Info
Gets the info for this activity.
public ActivityInfo Info { get; }
Property Value
Logger
Gets the logger scoped to this activity.
public ILogger Logger { get; }
Property Value
MetricMeter
Gets the metric meter for this activity with activity-specific tags. Note, this is lazily created for each activity execution.
public MetricMeter MetricMeter { get; }
Property Value
PayloadConverter
Gets the payload converter in use by this activity worker.
public IPayloadConverter PayloadConverter { get; }
Property Value
WorkerShutdownToken
Gets the cancellation token that is cancelled when the worker is shutdown. This can be used to gracefully handle worker shutdown for GracefulShutdownTimeout before CancellationToken will ultimately be cancelled.
public CancellationToken WorkerShutdownToken { get; }
Property Value
Methods
Heartbeat(params object?[])
Record a heartbeat on the activity.
public void Heartbeat(params object?[] details)
Parameters
details
object[]Details to record with the heartbeat if any.
Remarks
Heartbeats should be used for all non-immediately-returning, non-local activities and they are required to receive cancellation. Heartbeats are queued and processed asynchronously, so this will not error if the details cannot be converted. Rather any error converting heartbeat details will result in activity cancellation then activity failure.
Heartbeat calls are throttled internally based on the heartbeat timeout of the activity. Users do not have to be concerned with burdening the server by calling this too frequently.