I've got a WCF proxy that's using task-based operations. I'm making a method call that's wrapped in a Parallel.ForEach(). The service method I'm calling is a slow/long-running operation and occasionally returns exceptions. I'm not able to catch these exceptions in my catch block - never hits the block. The only way I'm able to catch exceptions is by using the synchronous service method. How do I catch the exceptions using the async service method? Is the exception being returned too late in the processing?
Parallel.ForEach(campaignResults.SelectMany(cd => cd), result =>
{
try
{
retList.TryAdd(client.SubmitRequestAsync(result.id, requestDetail), item.id);
}
catch (AggregateException ex)
{
// NEVER HIT ON EXCEPTION
foreach (Exception e in ex.InnerExceptions)
{
Trace.TraceError(e.ToString());
}
}
}
FaultException<T>should be thrown, shouldn't? Did you try to catch commonException? - Ilya Chumakov