ServiceRuntimeException が自己定義の例外である次のコードで、ServiceRuntimeException was unhandled by user code を取得しました。解決方法を教えてください。
List<Action> a=new List<Action>();
try
{
foreach (var parallelActivity in parallelActivities)
{
a.Add(delegate
{
try
{
parallelActivity.Execute();
}catch(ServiceRuntimeException e)
{
throw e;//<--Exception thrown at this line
}
});
}
Parallel.Invoke(a.ToArray());
}
catch (ServiceRuntimeException e)
{
throw e;
}catch(AggregateException e)
{
throw e.InnerExceptions[0];
}
ServiceRuntimeException の定義
public sealed class ServiceRuntimeException : Exception
{
public ServiceRuntimeException(string msg)
: base(msg)
{
}
}