private static void SafelyInvoke(string creationTrace, Delegate action, params object[] args) { Thread thread = Thread.CurrentThread; thread.LastException = null; thread.CreationStack = creationTrace; try { if (thread.StartStack == null) { thread.StartStack = StackTraceString(); } action.DynamicInvoke(args); } catch (Exception e) { thread.LastException = e; Issue(thread, e); if (!thread.HandleException(e)) { if (!NeverCrash) { throw thread.LastException; } } } finally { Notice(0, "Leaving callbackthread " + thread); thread.RunOnExit(); } }