|
1 | 1 | using System;
|
| 2 | +using System.Runtime.InteropServices; |
2 | 3 |
|
3 | 4 | namespace BenchmarkDotNet.Helpers
|
4 | 5 | {
|
5 | 6 | /// <summary>
|
6 |
| - /// Ensures that Dispose is called at termination of the Process. |
| 7 | + /// Ensures that explicit Dispose is called at termination of the Process. |
7 | 8 | /// </summary>
|
8 |
| - public class DisposeAtProcessTermination : IDisposable |
| 9 | + /// <remarks> |
| 10 | + /// <para> |
| 11 | + /// This class exists to help in reverting system state where C#'s using statement does not |
| 12 | + /// suffice. I.e. when Benchmark's process is aborted via Ctrl-C, Ctrl-Break or via click on the |
| 13 | + /// X in the upper right of Window. |
| 14 | + /// </para> |
| 15 | + /// <para> |
| 16 | + /// Usage: Derive your clas that changes system state of this class. Revert system state in |
| 17 | + /// override of <see cref="Dispose"/> implementation. |
| 18 | + /// Use your class in C#'s using statement, to ensure system state is reverted in normal situations. |
| 19 | + /// This class ensures your override is also called at process 'abort'. |
| 20 | + /// </para> |
| 21 | + /// <para> |
| 22 | + /// Note: This class is explicitly not responsible for cleanup of Native resources. Of course, |
| 23 | + /// derived classes can cleanup their Native resources (usually managed via |
| 24 | + /// <see cref="SafeHandle"/> derived classes), by delegating explicit Disposal to their |
| 25 | + /// <see cref="IDisposable"/> fields. |
| 26 | + /// </para> |
| 27 | + /// </remarks> |
| 28 | + public abstract class DisposeAtProcessTermination : IDisposable |
9 | 29 | {
|
10 | 30 | public DisposeAtProcessTermination()
|
11 | 31 | {
|
12 | 32 | Console.CancelKeyPress += OnCancelKeyPress;
|
13 | 33 | AppDomain.CurrentDomain.ProcessExit += OnProcessExit;
|
14 |
| - // It does not make sense to include a finalizer. As we are subscribed to static events, |
15 |
| - // it will never be called. |
| 34 | + // It does not make sense to include a Finalizer. We do not manage any native resource and: |
| 35 | + // as we are subscribed to static events, it would never be called. |
16 | 36 | }
|
17 | 37 |
|
18 | 38 | /// <summary>
|
|
0 commit comments