Skip to content

Improve Background Tasks module documentation - #19628

Open
agriffard wants to merge 3 commits into
mainfrom
agriffard-improve-background-tasks-docs
Open

Improve Background Tasks module documentation#19628
agriffard wants to merge 3 commits into
mainfrom
agriffard-improve-background-tasks-docs

Conversation

@agriffard

Copy link
Copy Markdown
Member

Summary

  • document activation, administration, scheduling, tenant scope, and host configuration
  • add compile-accurate custom task and registration examples
  • explain locking, cancellation, failure handling, logging, and troubleshooting

Validation

  • python -m mkdocs build --strict

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
public sealed class TenantMaintenanceBackgroundTask : IBackgroundTask
{
public Task DoWorkAsync(
IServiceProvider serviceProvider,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We need to use IServiceScopeFactory instead

Comment thread src/docs/reference/modules/BackgroundTasks/README.md Outdated
Co-authored-by: Hisham Bin Ateya <hishamco_2007@yahoo.com>
Comment thread src/docs/reference/modules/BackgroundTasks/README.md Outdated
Comment on lines +25 to +53
```csharp
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using OrchardCore.BackgroundTasks;

namespace MyModule;

public interface ITenantMaintenance
{
Task RunAsync(CancellationToken cancellationToken);
}

public sealed class TenantMaintenance : ITenantMaintenance
{
private readonly ILogger _logger;

public TenantMaintenance(ILogger<TenantMaintenance> logger)
{
_logger = logger;
}

public Task RunAsync(CancellationToken cancellationToken)
{
cancellationToken.ThrowIfCancellationRequested();
_logger.LogInformation("Tenant maintenance completed.");

return Task.CompletedTask;
}
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

this does not need to be part of the example. it lengthen the example for no reason. The IBackgroundTask implementation is enough

Co-authored-by: Mike Alhayek <mike@crestapps.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants