Skip to content

Commit 4a8d68c

Browse files
committed
Added support for asp.net cores application lifetime
http://www.khalidabuhakmeh.com/looking-at-asp-net-cores-iapplicationlifetime
1 parent 45d9e2f commit 4a8d68c

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

src/Platforms/Exceptionless.AspNetCore/ExceptionlessExtensions.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
using Exceptionless.Models;
88
using Exceptionless.Models.Data;
99
using Exceptionless.Plugins.Default;
10+
using Microsoft.AspNetCore.Hosting;
1011
using Microsoft.Extensions.Configuration;
1112
using Microsoft.Extensions.DependencyInjection;
1213

@@ -24,6 +25,9 @@ public static IApplicationBuilder UseExceptionless(this IApplicationBuilder app,
2425
var diagnosticListener = app.ApplicationServices.GetRequiredService<DiagnosticListener>();
2526
diagnosticListener?.SubscribeWithAdapter(new ExceptionlessDiagnosticListener(client));
2627

28+
var lifetime = app.ApplicationServices.GetRequiredService<IApplicationLifetime>();
29+
lifetime.ApplicationStopping.Register(() => client.ProcessQueue());
30+
2731
return app.UseMiddleware<ExceptionlessMiddleware>(client);
2832
}
2933

@@ -44,10 +48,10 @@ public static IApplicationBuilder UseExceptionless(this IApplicationBuilder app,
4448
/// <param name="settings">The configuration settings</param>
4549
public static void ReadFromConfiguration(this ExceptionlessConfiguration config, IConfiguration settings) {
4650
if (config == null)
47-
throw new ArgumentNullException("config");
51+
throw new ArgumentNullException(nameof(config));
4852

4953
if (settings == null)
50-
throw new ArgumentNullException("settings");
54+
throw new ArgumentNullException(nameof(settings));
5155

5256
var section = settings.GetSection("Exceptionless");
5357

src/Platforms/Exceptionless.AspNetCore/project.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{
1+
{
22
"version": "99.99.99-dev",
33
"title": "Exceptionless client for ASP.NET Core",
44
"authors": [ "Exceptionless" ],
@@ -32,6 +32,7 @@
3232
"Exceptionless": {
3333
"target": "project"
3434
},
35+
"Microsoft.AspNetCore.Hosting.Abstractions": "1.0.0",
3536
"Microsoft.AspNetCore.Http": "1.0.0",
3637
"Microsoft.AspNetCore.Http.Abstractions": "1.0.0",
3738
"Microsoft.AspNetCore.Http.Extensions": "1.0.0",

0 commit comments

Comments
 (0)