| DisposableReportNotDisposedObject Method |
Handle reporting of a not disposed object.
Using this pattern is a good practice to avoid code where disposable objects get never disposed.
Calling this method will raise the
NotDisposedObject event if any event handler is attached;
otherwise it will throw an
InvalidOperationException if a debugger is attached.
If the application does not run in a debugger and no event handler is attached, calling this method does nothing.
Namespace: TomsToolbox.EssentialsAssembly: TomsToolbox.Essentials (in TomsToolbox.Essentials.dll) Version: 2.21.0+44d18b541fc9419ec3c549350a832394661b2a4d
XMLNS for XAML: Not mapped to an xmlns.
Syntax public static void ReportNotDisposedObject(
this IDisposable obj
)
<ExtensionAttribute>
Public Shared Sub ReportNotDisposedObject (
obj As IDisposable
)
Parameters
- obj IDisposable
- The object for which to report the missing dispose call.
Usage Note
In Visual Basic and C#, you can call this method as an instance method on any object of type
IDisposable. When you use instance method syntax to call this method, omit the first parameter. For more information, see
Extension Methods (Visual Basic) or
Extension Methods (C# Programming Guide).
Example
Implement
IDisposable like this:
void Dispose()
{
Dispose(true);
GC.SuppressFinalize(this);
}
~MyClass()
{
this.ReportNotDisposedObject();
}
See Also