asp.net core - Disposing NServiceBus bus instance in MVC 6 -


in previous asp.net incarnations, nservicebus examples state create bus instance in global.asax. on dispose of application (in global.asax), mentioned instance of bus disposed. kind of abbreviated version below:

ibus bus;  protected void application_start() {     //bunch of bus configuration , controller registration etc...     //now create bus , assign local variable can dispose     var startablebus = bus.create(busconfiguration);     bus = startablebus.start(); }  public override void dispose() {     if (bus != null)     {         bus.dispose();     }     base.dispose(); } 

but in vnext, there no dispose in startup.cs know of. should instance of bus held on , disposed in way? there other pattern should followed vnext?

thanks!

if i'm not mistaken, looks add iapplicationlifetime configure , wait applicationstopping cancelled.

here snippet:

public void configure(iapplicationbuilder app, ihostingenvironment env, iloggerfactory loggerfactory, iapplicationlifetime lifetime) {    // new up/start bus here     lifetime.applicationstopping.register(() =>    {            // stop bus here    }); 

also looks planning have iapplicationlifetime.applicationstarted once release that, should able start bus there.


Comments