Shutdown and Draining

Learn more about the default behavior of our SDK if the application shuts down unexpectedly.

By default the SDK sends out events over the network on a background thread. This means that some events might be lost if the application shuts down unexpectedly. The SDK provides mechanisms to cope with this.

The .NET SDK gracefully handles shutdown, waiting up to ShutdownTimeout seconds to flush captured events.

This happens in a variety of different situations:

  • Automatically, in the case of a normal application exit.
  • Automatically, in the case of an unhandled exception.
  • Automatically, for integrations that use dependency injection (UseSentry, AddSentry, etc.).
  • Manually, if you dispose of the result of SentrySdk.Init (which is optional).
  • Manually, if you call SentrySdk.Flush or SentrySdk.FlushAsync.

In most cases, you can rely on the automatic approaches and don't need to worry about this.

Was this helpful?
Help improve this content
Our documentation is open source and available on GitHub. Your contributions are welcome, whether fixing a typo (drat!) or suggesting an update ("yeah, this would be better").