Skip to main content

Background Tasks

Some work shouldn’t block the HTTP response — sending emails, processing images, updating search indexes. PrismBackgroundTaskManager runs tasks in the background with tracking and cancellation support.

Fire and Forget

Background Task

Tasks with Results

When you need the result later:
Get Task Result

Monitoring Active Tasks

Check Running Tasks

Cancellation

Cancel Tasks

Task Groups

Group related tasks and wait for all of them:
Task Group

Practical Example: Image Processing Pipeline

Upload + Background Processing
Fire-and-forget tasks (run) swallow errors silently. If you need error handling, use runWithResult and try await task.value, or handle errors inside the task closure itself.
Register a shutdown hook to cancel background tasks during graceful shutdown. Otherwise, in-flight tasks may be interrupted abruptly when the process exits.