private static bool IsCriticalException(Exception ex)
{
return ex is NullReferenceException
|| ex is StackOverflowException
|| ex is OutOfMemoryException
//|| ex is System.Threading.ThreadAbortException
|| ex is IndexOutOfRangeException
|| ex is AccessViolationException;
}