I have create Hangfire Application with multiple operations. One of operation which generate Pdf file using wkhtmltopdf wrapper. Which use process to execute wkhtmltopdf.exe file to create Pdfs.
I worked fine for 5, 6 pdfs. However it didn’t worked for 200+ pdfs. It keeps throwing below error.
Application: w3wp.exe
Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: System.InvalidOperationException
at System.Threading.Tasks.TaskCompletionSource`1[[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]].SetResult(System.__Canon)
at Hangfire.Processing.BackgroundDispatcher.DispatchLoop()
at System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object)
at System.Threading.ThreadHelper.ThreadStart()
An unhandled exception occurred and the process was terminated.
Application ID: /LM/W3SVC/3/ROOT
Process ID: 14880
Exception: System.InvalidOperationException
Message: An attempt was made to transition a task to a final state when it had already completed.
StackTrace: at System.Threading.Tasks.TaskCompletionSource`1.SetResult(TResult result)
at Hangfire.Processing.BackgroundDispatcher.DispatchLoop()
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()