It was my assumption that the finally block always gets executed as long as the program is running. However, in this console app, the finally block does not seem to get executed.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
try
{
throw new Exception();
}
finally
{
Console.WriteLine("finally");
}
}
}
}
Output
Note: When the exception was thrown, windows askmed me if I wanted to end the appliation, I said 'Yes.'
no
and see what happens – Sapowith