When using Tasks you have to take special care in handling exceptions, here is an example :
class Program
{
static void Main(string[] args)
{
Task<int> task = new Task<int>(Test);
task.ContinueWith(ExceptionHandler, TaskContinuationOptions.OnlyOnFaulted);
task.Start();
Console.ReadLine();
}
static int Test()
{
throw new Exception();
}
static void ExceptionHandler(Task<int> task)
{
var exception = task.Exception;
Console.WriteLine(exception);
}
}
From here
My question is if there is any way to make a custom Task that will handle(log to service) all exceptions without manually stating it by the developer? Some kind of help heritage.