When trying to compile a call to HtmlHelper.Partial
in an ASP.NET Core MVC application, I get the following warning:
warning MVC1000: Use of IHtmlHelper.Partial may result in application deadlocks. Consider using Tag Helper or IHtmlHelper.PartialAsync.
There is lots of advice online that suggests following this warning. What I am looking for is to understand the root cause of this so that I can see if other coding patterns not using HtmlHelper.Partial might lead to similar issues.
The only explanation I've found so far is in this locked thread, which says that it has to do with taking up "task slots" but does not go into detail.
I can imagine a deadlock case where EVERY threadpool thread was blocked synchronously waiting on some Task
and none of those tasks could complete because they were waiting to be scheduled on the threadpool threads AND the threadpool is at max threads and won't allocate more, but this seems like something that could happen with any sync-over-async code and feels somewhat unlikely with a high max thread count, so I'm guessing that there is something more to it.
Note: Tag Helper vs HTML Helper "Use of IHtmlHelper.Partial may result in application deadlocks" mentions this but is more focused on TagHelpers (as is the response)