SEHCleanup Sample: Demonstrates Writing Cleanup Code Using __finally for a Try-Catch Block Involving Common Language Runtime Exceptions
The SEHCleanup sample illustrates throwing an instance of System::Exception, catching it in a catch handler, and then doing cleanup using a __finally clause before passing the control to the next statement. The sample also shows how to catch the common language runtime exception and rethrow it, and the use of nested try-catch statements.
Building and Running the Sample
To build and run SEHCleanup using Visual Studio
- In the Visual Studio IDE, load the solution file SEHCleanup.sln.
- In Solution Explorer, right-click the SEHCleanup solution.
- On the shortcut menu, click Build.
- On the Debug menu, click Start.
The following output is displayed in the console window:
Inner Catch Inner Finally Outer Catch Outer Finally
Classes and Keywords
This sample demonstrates the following class:
This sample demonstrates the following keywords:
try, catch, throw, __finally