How to setup Hangfire?

Has anyone been able to successfully been able to setup hangfire in COT?
1 person has
this question
+1
Reply
  • We do not recommend running lengthy background tasks in the apps. The hosting environment can recycle process at any time. For example, if you app is idle (no incoming requests then IIS will recycle the poll process). Hangfire cannot prevent the process termination. Hangfire does provide a log of all jobs and will retry them when the process is restarted.

    For example, let's say a background import process was started at 2:00 PM and it takes 16 hours to complete. The last app user goes home at 5:00 PM on Thursday and there are no requests coming in. The host terminates at 5:20 PM. Nothing is being processed overnight. The first user of the next days goes live at 8:55 AM. Hangfire will restart the process but the last user of the day goes home at 4:30 PM. You import will terminate at 4:50 PM. Nobody is working on the weekend. Import will continue on Monday morning.

    If you have short tasks that can run in the background to speed up server response to user actions then Hangfire will work well. Also consider using the ThreedPool class for such tasks. For example, appication framework uses standard ThreadPool class to send emails from business rules. The email is constructed on the server and the delivery is performed in a separate thread. The user gets control over the app as soon as the email delivery is outsourced to the ThreadPool. The physical communication of the thread with the SMTP server may take from a few seconds to a minute or longer. User does not need to wait for this to complete.

    If you web server is a dedicate or virtual server then consider creating a command line app that is being started by Windows Scheduler. Do all background processing there. You can also get a cheap cloud VM for that. Services such as Azure Jobs are a good choice as well.
  • (some HTML allowed)
    How does this make you feel?
    Add Image
    I'm

    e.g. indifferent, undecided, unconcerned happy, confident, thankful, excited kidding, amused, unsure, silly sad, anxious, confused, frustrated