Giving resources backbeginner
A file handle or socket you opened is yours to release — the Dispose pattern is how a caller gets to say "I am finished with this" instead of waiting for a collection that may never come.
A background worker takes a DbContext in its constructor and holds it for the life of the process. It works in development, survives review, and fails under load as one connection is shared by everything. Resolve the scope where the work happens instead.
The worker holds nothing scoped, and every unit of work gets its own scope and its own context.
Published in full, before you start — every point is one of these and there is nothing else.
A file handle or socket you opened is yours to release — the Dispose pattern is how a caller gets to say "I am finished with this" instead of waiting for a collection that may never come.
A hardcoded API secret is a secret in your git history; IOptions<T> binds configuration into a typed object your code asks for like anything else.