/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Program_AggregateExceptionCatched(object sender, AggregateExceptionArgs e) { foreach (Exception item in e.AggregateException.InnerExceptions) { logAction(item); } }
/// <summary> /// /// </summary> /// <param name="task"></param> /// <returns></returns> private Task ContinueWith(Task task) { return(task.ContinueWith(t => { if (t.Exception != null) { AggregateExceptionArgs errArgs = new AggregateExceptionArgs() { AggregateException = new AggregateException(t.Exception.InnerExceptions) }; AggregateExceptionCatched(null, errArgs); } }, TaskContinuationOptions.OnlyOnFaulted)); }