Shutdown and Draining
Learn more about the default behavior of our SDK if the application shuts down unexpectedly.
The default behavior of most SDKs is to send out events over the network asynchronously in the background. This means that some events might be lost if the application shuts down unexpectedly. The SDKs provide 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
orSentrySdk.FlushAsync
.
In most cases, you can rely on the automatic approaches and don't need to worry about this.
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").
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").