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
You may create it with TaskCreationOptions.AttachedToParent. According to Nested Tasks and Child Tasks (MSDN), Exceptions are then propagated to your thread. I do not know, however, whether this is elegant or not.
Microsoft does not recommend this "in most cases". Somebody else might know in what case this may be sensible. From the same article:
You can use attached child tasks to create tightly-synchronized graphs of asynchronous operations. However, in most scenarios, we recommend that you use nested tasks because the relationships with other tasks are less complex. That is why tasks created inside other tasks are nested by default, and you must explicitly specify the AttachedToParent option to create a child task.
Cheers, Matthias