Is there an exception in .NET like Delphi EAbort?

Is there an exception in .NET like Delphi EAbort?

I am currently defining my own "AbortProcess" inheriting Exception. Together with the My.Application.UnhandledException handler, which ignores the "AbortProcess", I'm still wondering if a similar mechanic exists in .NET.

Class AbortProcess
    Inherits System.Exception
End Class

Sub Abort()
    Throw New AbortProcess()
End Sub

Sub AppDomain_UnhandledException(ByVal sender As Object, ByVal e As ApplicationServices.UnhandledExceptionEventArgs)
    If TypeOf e.Exception Is AbortProcess Then
        e.ExitApplication = False
    End If
End Sub    

Sub PerformActions()
    Action1()
    If Not Action2() Then
        Abort()
    End If
    Action3()
    ...
End Sub

How does a typical .NET developer handle this use case?

UPDATED:

, , . , , , , ; . , ANTLR , (RecognitionException) . Python StopIteration, , Exception . , Delphi VCL.

+3
4

, Delphi EAbort.

  • IDE , , .
  • EAbort , .

, , , . Visual Studio ; . , Visual Studio try/catch ? , .

EAbort , . , , , , , . , finally, , , , .

+5

, , ThreadAbortException, ", Abort."

0

.Net, . , , . , ThreadAbortException, , .

- Environment.Exit.

, , CLR ( ).

0

, . .NET , - .

. , - , , . UnhandledException - , ( , , "" ).

, , :

try {
    PerformActions()
} catch (AbortProcess) {
    //do some cleaning up or just ignore
}

, , . UnhandledException, .

0

Source: https://habr.com/ru/post/1713923/


All Articles