The ScanFix® Xpress .NET Windows Forms component implements the Dispose pattern which is defined by the IDisposable interface. Because ScanFix Xpress encapsulates unmanaged resources and is a non-windowed component, the Dispose method MUST be called for each instance of the ScanFix Xpress object, to allow the release of all resources.
It is recommended to call the ScanFix Xpress Dispose method from the components' container. For example, in all .NET Windows Forms applications, you will find a generated call to Dispose such as:
C# Example |
Copy Code |
protected override void Dispose (bool disposing)
{
if (disposing)
{
if (components != NULL)
{
components.Dispose ();
}
//added for ScanFix
scanFix1.Dispose ();
}
base.Disposing (disposing);
} |
While the above is the recommended approach, the application developer is not required to call Dispose at this location. Essentially, the developer can make the call to clean up these resources at any desired time during the components' containers lifetime. Adding this line means that the Dispose method of the control gets explicitly called when the form is disposed of.
Additionally, if ScanFix Xpress instances are created dynamically at runtime, each instance must call its own Dispose method to allow all resources to be released.