The SmartZone ICR and SmartZone OCR Windows Forms components implement the Dispose pattern which is defined by the IDisposable interface. Because SmartZone encapsulates unmanaged resources and is a non-windowed component, the Dispose method MUST be called for each instance of the SmartZone ICR object and SmartZone OCR object to allow the release of all resources.
It is recommended to call the SmartZone ICR Dispose method (and/or SmartZone OCR Dispose method) from the components' container. For example, in all Windows Forms applications, you will find a generated call to Dispose such as:
protected override void Dispose(bool disposing)
{
if (disposing)
{
if (components != NULL)
{
components.Dispose();
}
// Added for SmartZone ICR.
szicr.Dispose();
}
base.Disposing(disposing);
}
protected override void Dispose(bool disposing)
{
if (disposing)
{
if (components != NULL)
{
components.Dispose();
}
// Added for SmartZone OCR.
szocr.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 SmartZone ICR or SmartZone OCR instances are created dynamically at runtime, each instance must call its own Dispose method to allow all resources to be released.