private static bool IsFatalException(Exception exception)
{
while (exception != null)
{
if ((exception is OutOfMemoryException)
|| (exception is InsufficientMemoryException)
|| (exception is ThreadAbortException))
{
return true;
}
if (!(exception is TypeInitializationException) && !(exception is TargetInvocationException))
{
break;
}
exception = exception.InnerException;
}
return false;
}
}