Does .NET has an Exception that similar to Delphi's EAbort ?
Currently, I define my own "AbortProcess" inheriting Exception. Together with My.Application.UnhandledException handler that ignoring "AbortProcess" I'm still wondering if similar mechanic in .NET is already exists.
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 typical .NET developer handle this use case ?
UPDATED:
For some reasons a number of people down vote this question, unfortunately, without giving any comment. The only reason I can figure out is that they might believe Exception should never be used to control program flow; and I tend to agree with that. However, I recently study ANTLR and find that they indeed use custom Exception (RecognitionException) as control flow construct. Together with Python's StopIteration usage, I believe that using Exception as control flow construct is actually already being used broadly. It's just not being standardize like in Delphi VCL.