Finally is not executed when in a Thread running in a Windows Service
Can anyone explain why this finally block is not executed? I have read posts about when to expect finally block not be executed, but this seems to be another case. This code needs TopShelf and log4net. I am running .net 4.5 I guess it must be the Windows Service engine that kicks in on unhandled exceptions, but why is it running before the finally block has finished? using log4net; using log4net.Config; using System; using System.Threading; using Topshelf; namespace ConsoleApplication1 { public class HostMain { static void Main(string[] args) { HostFactory.Run(x => { x.Service<HostMain>(s => {