There are several options available to execute custom code as part of the endpoint's startup/shutdown sequence:
- Writing code directly after calling
Endpoint.
orStart endpointInstance.
.Stop - Adding a custom FeatureStartupTask.
- Using MEF or Reflection to run code at startup and shutdown in a pluggable way.
The
IWantToRunWhenBusStartsAndStops
interface is no longer available as part of the NServiceBus
package.Hooking into endpoint lifecycle when using the hosts
Some of the described approaches are not available when hosting an endpoint via the NServiceBus.
or NServiceBus.
packages. Visit their respective documentation pages for more information on how to hook into the startup/shutdown sequence:
- In the NServiceBus Host.
- In the AzureCloudService Host.