I want to do some cleanup in a library when the process is being closed, what is the DotNet Core alternative for that? In .Net Framework 4 I used AppDomain.CurrentDomain.ProcessExit.
Since your code is in a library you can make the caller of the library provide a notification. That way the host can decide to notify you.
Normally, a library is not supposed to mess with process global state. It should not assume much about the environment it's being hosted it.
Maybe the caller can pass a Task
that becomes completed when process shutdown starts. Or, the caller can call a static method on your library (NotifyProcessShutdown
or PerformProcessShutdownCleanup
).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With