hi,
i just wanted to bring attention to this new feature and if it helps Hangfire
http://blogs.msdn.com/b/dotnet/archive/2014/05/05/announcing-the-net-framework-4-5-2-release.aspx
Unfortunately, the QueueBackgroundWorkItem
method just wraps ThreadPool.QueueUserWorkItem
call with HostingEnvironment.RegisterObject
and HostingEnvironment.UnregisterObject
and sends exception details to EventLog.
ASP.NET still uses shutdown timeout, that cause your background jobs to be aborted after 30 sec by default. Yes, there is CancellationToken
, and I can cancel my background job during shutdown event, and it will not be aborted. But I should be able to start this job again after application restart – and there is no such feature.
So, this solution satisfies only these cases, when background jobs are:
- small enough to complete at shutdown for N seconds.
- large, and you are going to implement retry logic (after restarts and after exceptions), but this is hard.
If you want to use background jobs in your application and want to stop thinking about reliability issues, you should use HangFire or other libraries that use message queues and reliable fetching.
And thanks, I wanted to write about it, but forgot to do it.
this is great to hear, because it proves that even with the new .NET Update, HangFire still has the Edge