I debounce file change notifications like this:
ChangeToken.OnChange(
() => GetReloadToken(),
async () => await debouncer.Debounce(OnReloaded) // <--- concern
);
There is no async overload for ChangeToken.OnChange
, but hopefully there will be in v7.
That code's been working for years without error. But now I'm using a code analyser which complains that I'm using a fire-and-forget (async void
), and that exceptions could crash the process - unlikely in this particular case, but I want to reevaluate anyway.
There are other ways to write that action, e.g. () => debouncer.Debounce(OnConfigReloaded).ConfigureAwait(false)
, but I'm unsure which is "safest" (or the one with the least problems).
So, until there's an async overload, what is the safest way to write that action?
PS, if an async overload matters to you, please upvote the issue on the repo.