Table of Contents

Interface IExecuteInBackground

Namespace
Excalibur.Dispatch.Threading
Assembly
Excalibur.Dispatch.dll

Marker interface for messages that should be executed in the background.

public interface IExecuteInBackground
Extension Methods

Remarks

Messages implementing this interface are handed to a background worker, and the dispatch returns immediately with a successful result whose disposition is AcceptedForBackgroundExecution: the work is accepted and pending, and the handler has not run yet. Messages expecting typed results cannot implement this interface as background execution does not support returning values to the caller.

A dispatch whose cancellation token is already cancelled is not accepted: the handler never runs and the result is cancelled. Once accepted, the work no longer follows the caller's token, which is often request-scoped and fires when the response carrying the acceptance completes.

Background execution is decoupled, not durable. A graceful host shutdown waits for in-flight background work, bounded by HostOptions.ShutdownTimeout; work still running when that budget elapses is signalled to cancel, and an error is logged for it. An abrupt termination still loses in-flight work, which is inherent to running in-process. Work that must survive a crash or restart belongs in the outbox.

What happens when background work fails is a host-level policy, not a property of the message: see ExceptionBehavior.