Problems with windows service, blockingcollection, and Multithreading
问题 My scenario: Windows Service .NET 4 I poll a database for entities. When new entities come in they are added to a BlockingCollection . In the service's OnStart I create a System.Threading.Tasks.Task whose job is to enumerate the BlockingCollection (using GetConsumingEnumerable() ). The problem I'm having is this: When an unhandled exception occurs in the task, I want the exception logged and the service stopped. I can't catch exceptions from the task unless I call Task.Wait() . If I call Task