The problem still exists.
Previously written related articles asynchronous programming articles, this article is mainly a little supplement, before the IIS often send w3wp process no hanging, but has not been able to find the real reason, and find relevant information, find some related articles, such as await and async caused by thread deadlock , have also been analyzed, but the situation with our project is somewhat different, because in our project only use ThreadPool and task.run this thread pool, and asynchronous use is also asynchronous to the end !
Today inadvertently saw an article, said in the ThreadPool if there is an exception, and you do not capture it, directly throw, this will also refer to the death of the w3wp process, I tried on the computer, there is such a situation, so very excited!
In the Event Viewer,
Finally, my thread pool method has been improved to solve this problem.
Optimized code
/// <summary> ///Thread Management/// </summary> Public classThreadmanager {/// <summary> ///queue The specified work running on the thread pool/// </summary> /// <param name= "action" ></param> Public Static voidRun (Action action) {ThreadPool.QueueUserWorkItem (U= { Try{action (); } Catch(Exception ex) {Lind.DDD.Logger.LoggerFactory.Instance.Logger_Error (ex); } }); } }
Finally, it is very happy to find another cause of the w3wp process hanging off, I hope this time can really solve this problem!
c#~ Asynchronous Programming Continue ~ You have to know the throw in the ThreadPool