I am building a Windows Service with .NET 4.0.
I have various unhandled exceptions thrown in Tasks, but they do not terminate my process as the MSDN documentation st
According to this nice blog post if you want to crash your app as soon as you have unhandled exception in your task then you can continue your task something like below:
public static Task FailFastOnException(this Task task)
{
task.ContinueWith(c => Environment.FailFast(“Task faulted”, c.Exception),
TaskContinuationOptions.OnlyOnFaulted |
TaskContinuationOptions.ExecuteSynchronously |
TaskContinuationOptions.DetachedFromParent);
return task;
}