question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Not able to use inside Worker template

See original GitHub issue

1. When running with RunTargetsAndExit

 protected override async Task ExecuteAsync(CancellationToken stoppingToken)
        {
            while (!stoppingToken.IsCancellationRequested)
            {
                Target("default", () => System.Console.WriteLine("Hello, world!"));
                RunTargetsAndExit(decimal);
                _logger.LogInformation("Worker running at: {time}", DateTimeOffset.Now);
                await Task.Delay(1000, stoppingToken);
            }
        }

It runs first time but stops the application and gets stuck on

Waiting for the host to be disposed. Ensure all 'IHost' instances are wrapped in 'using' blocks.

image

2. When running with RunTargetsWithoutExiting

 protected override async Task ExecuteAsync(CancellationToken stoppingToken)
        {
            while (!stoppingToken.IsCancellationRequested)
            {
                Target("default", () => System.Console.WriteLine("Hello, world!"));
                RunTargetsWithoutExiting(default);
                _logger.LogInformation("Worker running at: {time}", DateTimeOffset.Now);
                await Task.Delay(1000, stoppingToken);
            }
        }

It runs first time but gets stuck on

image

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
adamralphcommented, Jun 29, 2020

@iAmBipinPaul the problem is that this line, when executed a second time, throws an exception:

Target("default", () => System.Console.WriteLine("Hello, world!"));

This can be seen when setting VS to break when CLR exceptions are thrown:

image

I guess something in Microsoft.Hosting.Extensions is swallowing the exception.

Anyway, I believe we’ve determined that Bullseye is behaving as expected, so on that basis I’m closing the issue.

1reaction
adamralphcommented, Jun 29, 2020

Thanks @iAmBipinPaul, I’ll take a look ASAP.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Worker Service - Missing Template · Issue #29940
After installing all prerequisites, the "Worker Service" template does still not appear in my list of project templates.
Read more >
templates - Visual Studio 2022 Worker Service
I found this article useful: Where default templates are stored Note Visual Studio 2022 gets installed under Program Files (64 bit, not 86x) ......
Read more >
Templates Not Showing in Create New Work Item
For my Azure DevOps project I am both an Administrator and Collaborator. In Team Configuration I have created templates for User Stories. I...
Read more >
Worker Services - .NET
Learn how to implement a custom IHostedService and use existing implementations in C#. Discover various worker implementations, templates, ...
Read more >
Worker Services in .NET Core 3.0 - The New Way ... - YouTube
In .NET Core 3.0, Microsoft has added a template called a Worker Service ... App template code overview 9:32 - Service App code...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found