ASP.NET Core support #94

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

Comments

Projects
None yet
5 participants
@tallesl
Contributor

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 jpsingleton referenced this issue in jpsingleton/ANCLAFS Aug 8, 2016

Closed

Add schedulers #11

@jpsingleton

This comment has been minimized.

Show comment
Hide comment
@jpsingleton

jpsingleton 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."

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

This comment has been minimized.

Show comment
Hide comment
@tallesl

tallesl Aug 8, 2016

Contributor

@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.

Contributor

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

This comment has been minimized.

Show comment
Hide comment
@raupes

raupes Nov 1, 2016

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

raupes commented Nov 1, 2016

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

@tallesl

This comment has been minimized.

Show comment
Hide comment
@tallesl

tallesl Nov 5, 2016

Contributor

Published a JobManager.StopAndBlock method on version 5.1.0.

Contributor

tallesl commented Nov 5, 2016

Published a JobManager.StopAndBlock method on version 5.1.0.

@tallesl tallesl closed this Nov 5, 2016

@KANekT

This comment has been minimized.

Show comment
Hide comment
@KANekT

KANekT Nov 5, 2016

Add please documentation for use in README.md

KANekT commented Nov 5, 2016

Add please documentation for use in README.md

@jpsingleton

This comment has been minimized.

Show comment
Hide comment

@tallesl tallesl removed the help wanted label Nov 19, 2016

@itavero

This comment has been minimized.

Show comment
Hide comment
@itavero

itavero Aug 3, 2017

@tallesl When will the README be updated?

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