이 접근 방법은 예외가 전파되지 않도록하기 때문에 안전하다고 생각했습니다. 내 동료는 예외가 주 스레드에서 관찰되어야 할 수도 있으므로 주 스레드까지 전달해야한다고 제안했습니다. 그 대답인가? 이것을 통해 누수가 누출 될 수있는 것을 볼 수 있습니까?예외가이 작업을 어떻게 넘어 설 수 있습니까?
private static void InvokeProcessHandlers<T>(List<T> processHandlers, Action<T> action)
{
// Loop through process handlers asynchronously, giving them each their own chance to do their thing.
Task.Factory.StartNew(() =>
{
foreach (T handler in processHandlers)
{
try
{
action.Invoke(handler);
}
catch (Exception ex)
{
try
{
EventLog.WriteEntry(ResourceCommon.LogSource,
String.Format(CultureInfo.CurrentCulture, "An error occurred in a pre- or post-process interception handler: {0}", ex.ToString()),
EventLogEntryType.Error);
}
catch (Exception)
{
// Eat it. Nothing else we can do. Something is seriously broken.
}
continue; // Don't let one handler failure stop the rest from processing.
}
}
});
}
그런데 스택 추적은 실제로이 메서드에서 예외가 누수되었음을 나타냅니다.
예외는 AccessViolation이며, 나는이 방법을 호출하는 코드와 함께 할 가지고 있다고 생각합니다 :
_interceptionPreprocessHandlers = ReflectionUtility.GetObjectsForAnInterface<IInterceptionPreprocessHandler>(Assembly.GetExecutingAssembly());
최소한 로그 할 수 있습니다! – Joe
foreach 열거 자 자체에서 예외가 throw되지 않는 한 당신이 훌륭하다고 생각합니다. 즉,이 모든 예외를 실제로 사용 하시겠습니까? –