Skip to content

Instantly share code, notes, and snippets.

@changhuixu
Last active May 31, 2020 22:55
Show Gist options
  • Select an option

  • Save changhuixu/7a5c0bdf163dcdb9bdda93ea7f8b0ca8 to your computer and use it in GitHub Desktop.

Select an option

Save changhuixu/7a5c0bdf163dcdb9bdda93ea7f8b0ca8 to your computer and use it in GitHub Desktop.
public void Configure(IApplicationBuilder app, IWebHostEnvironment env, IHostApplicationLifetime hostApplicationLifetime)
{
// ...
hostApplicationLifetime.ApplicationStarted.Register(() => { });
hostApplicationLifetime.ApplicationStopping.Register(() =>
{
var rabbitMqClient = app.ApplicationServices.GetRequiredService<IRabbitMQClient>();
rabbitMqClient.CloseConnection();
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment