Skip to content
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

ServiceWorker suggestions #58

Open
carsten-riedel opened this issue Mar 27, 2024 · 0 comments
Open

ServiceWorker suggestions #58

carsten-riedel opened this issue Mar 27, 2024 · 0 comments

Comments

@carsten-riedel
Copy link

carsten-riedel commented Mar 27, 2024

Hi,

nearly did the same, than found your project, nice work !!!

Regarding your Service Worker some suggestion, maybe it makes sense to use a BackgroundService ExecuteAsync and await for appLifetime.ApplicationStarted.
I don't like the fixed _hostLifetime.StopApplication(); either. I should be open who decides to quite the application, it could be done on a command level with _hostLifetime.StopApplication();
Maybe even individual configuration of the worker could be passed via UseSpectreConsole + Action< SpectreServiceWorkerConfig >

 public Task StartAsync(CancellationToken cancellationToken)
    {
        return Task.Factory.StartNew(async () =>
        {
            try
            {
                var args = GetArgs();
                await Task.Delay(100, cancellationToken); //Just to let Microsoft.Hosting finish.
                _exitCode = await _commandApp.RunAsync(args);
            }
            catch (Exception ex)
            {
                _logger.LogError(ex, "An unexpected error occurred");
                _exitCode = 1;
            }
            finally
            {
                _hostLifetime.StopApplication();
            }
        }, cancellationToken);
    }
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

No branches or pull requests

1 participant