Skip to content

Short-lived hosted scenario. #46460

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
May 28, 2025
Merged

Short-lived hosted scenario. #46460

merged 4 commits into from
May 28, 2025

Conversation

IEvangelist
Copy link
Member

@IEvangelist IEvangelist commented May 28, 2025

Summary

Add and detail an alternative approach to signaling completion for short-lived hosted scenarios.

Fixes #45902


Internal previews

📄 File 🔗 Preview link
docs/core/extensions/workers.md Worker services in .NET

@IEvangelist IEvangelist requested review from Copilot and removed request for a team May 28, 2025 14:02
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR expands guidance on signaling completion for short-lived hosted services and introduces an alternative generic host approach for such scenarios.

  • Updated metadata date and refined wording around signaling completion.
  • Added a new “Alternative approach” section with sample csproj, Program, and JobRunner code.
  • Demonstrates using the .NET Generic Host for run-once applications without a Worker class.

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
docs/core/extensions/workers.md Bumped ms.date, clarified ExecuteAsync link, expanded IMPORTANT note, and added an “Alternative approach” section.
docs/core/extensions/snippets/hosts/ShortLived.App.csproj Introduced sample project file for a short-lived generic host app.
docs/core/extensions/snippets/hosts/Program.cs Added example Program.cs using top-level statements, DI, and logging.
docs/core/extensions/snippets/hosts/JobRunner.cs Added JobRunner class with primary constructor syntax and RunAsync.
Comments suppressed due to low confidence (1)

docs/core/extensions/snippets/hosts/ShortLived.App.csproj:1

  • [nitpick] Consider using the base SDK (Microsoft.NET.Sdk) instead of Microsoft.NET.Sdk.Worker to better reflect a generic host project rather than a Worker service template.
<Project Sdk="Microsoft.NET.Sdk.Worker">

@IEvangelist IEvangelist enabled auto-merge (squash) May 28, 2025 15:26
@IEvangelist IEvangelist merged commit 37fd367 into dotnet:main May 28, 2025
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Signal Completion is missing documentation about stopping host for non-success scenarios
2 participants