处理未处理的exception后恢复程序执行

问题:我通常使用AddHandler System.AppDomain.CurrentDomain.UnhandledException, AddressOf OnUnhandledException捕获未处理的exception。

现在的问题是,使用此exception处理程序

 Public Sub OnUnhandledException(ByVal sender As Object, ByVal e As UnhandledExceptionEventArgs) Console.WriteLine(e.ExceptionObject.ToString()) Console.WriteLine("Press Enter to continue") Console.ReadLine() 'Environment.Exit(1) End Sub 

如果我不退出程序,程序执行仍会抛出exception。
现在我想知道如何将其更改为“on error resume next”行为? 有可能吗?

   _ Public Sub Main(ByVal argv As String()) 'For i As Integer = 0 To argv.Length - 1 Step 1 'Console.WriteLine("Argument {0}: {1}", i, argv(i)) 'Next i AddHandler System.AppDomain.CurrentDomain.UnhandledException, AddressOf OnUnhandledException Throw New Exception("Test") Console.WriteLine("Continue") End sub 

如果要在程序退出之前执行除快速记录或警告用户exception之外的任何操作,则需要使用try/catch块正常处理exception。 应尽快处理例外情况,以便做出如何应对的真正决定。 UnhandledException可能听起来像是集中所有exception处理的好地方,但这不是它的预期目的,如果必须处理应用程序中任何地方抛出的每个exception,它会变得非常复杂。