How to use IBackgroundProcessAsync (keeping Mailkit alive)

I found an async version of the IBackgroundProcess, but I can’t find a way to hook it up. The non async interface could be hooked up through DI or passed in to AddHangfireServer. Documentation is also nonexistent for either of IBackgroundProcess or IBackgroundProcessAsync. I want to use the IBackgroundProcessAsync to keep a MailKit Smtp client alive, so the connection isn’t lost if no emails come into the system for a bit. The Hangfire service runs on more than 1 server, and couldn’t really find a way to get a recurring job to run on every server.

1 Like