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

ASP.NET Core support #94

Closed
tallesl opened this issue Aug 7, 2016 · 7 comments
Closed

ASP.NET Core support #94

tallesl opened this issue Aug 7, 2016 · 7 comments

Comments

@tallesl
Copy link
Contributor

@tallesl tallesl commented Aug 7, 2016

While the library supports .NET Core, it's not already clear what would be needed to support running it with ASP.NET Core.

You can find out when ASP.NET Core is shutting down with the following Startup.cs (adapted Getting Started):

using System;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;

namespace aspnetcoreapp
{
    public class Startup
    {
        public void Configure(IApplicationBuilder app, IApplicationLifetime lifetime) // added the IApplicationLifetime parameter
        {
            app.Run(context =>
            {
                return context.Response.WriteAsync("Hello from ASP.NET Core!");
            });
            lifetime.ApplicationStopping.Register(() => Console.WriteLine("Bye from ASP.NET Core!")); // added this line
        }
    }
}

But then there's two problems one problem:

@tallesl tallesl added the on hold label Aug 7, 2016
This was referenced Aug 7, 2016
@jpsingleton
Copy link

@jpsingleton jpsingleton commented Aug 8, 2016

I'm not sure if this is exactly what you're having problems with but as I wrote about this as part of my recent book I thought I'd chip in.

You can do a blocking shutdown to approximate what HostingEnvironment.QueueBackgroundWorkItem (QBWI) does in the full .NET Framework (>= 4.5.2). You can get the ApplicationStopping cancellation token from lifetime (as in your example above) and wait on that. There is also an ApplicationStopped token than hooks in slightly later in the life-cycle.

The docs say that for both; "Shutdown will block until this event completes."

@tallesl
Copy link
Contributor Author

@tallesl tallesl commented Aug 8, 2016

@jpsingleton

Thank you very much for your input.

There's still a blocking problem on our part (#93) but as soon I got it fixed I'll add an example on how to use the library with ASP.NET Core on our README.

@tallesl tallesl added help wanted and removed on hold labels Aug 8, 2016
@raupes
Copy link

@raupes raupes commented Nov 1, 2016

Hi, any improvements for hosting in asp.net core so far?

@tallesl
Copy link
Contributor Author

@tallesl tallesl commented Nov 5, 2016

Published a JobManager.StopAndBlock method on version 5.1.0.

@tallesl tallesl closed this Nov 5, 2016
@KANekT
Copy link

@KANekT KANekT commented Nov 5, 2016

Add please documentation for use in README.md

@jpsingleton
Copy link

@jpsingleton jpsingleton commented Nov 5, 2016

Thanks! I've updated ANCLAFS.com (jpsingleton/ANCLAFS@f54b6a7).

@tallesl tallesl removed the help wanted label Nov 19, 2016
@itavero
Copy link

@itavero itavero commented Aug 3, 2017

@tallesl When will the README be updated?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
5 participants
You can’t perform that action at this time.