Condividi tramite


GestureRecognizer.Dispose Method

GestureRecognizer.Dispose Method

Releases all resources used by the object.

Definition

Visual Basic .NET Public Sub Dispose()
C# public void Dispose();
Managed C++ public: void Dispose();

Remarks

Calling frlrfmicrosoftstylusinputgesturerecognizerclassdisposetopic (no caption;) allows the resources used by the object to be reallocated for other purposes. For more information about garbage collection, see Programming for Garbage Collection Leave Site.

Caution: To avoid a memory leak you must explicitly call this method on any object or control in the Microsoft® Windows® XP Tablet PC Edition Software Development Kit (SDK) to which an event handler has been attached before the object or control goes out of scope.

For any class in the Tablet PC SDK on which frlrfmicrosoftstylusinputgesturerecognizerclassdisposetopic (no caption;) is defined, manually dispose of each instance of that class when it is no longer needed. Disposing of these objects will improve your application's performance.

When overriding the frlrfmicrosoftstylusinputgesturerecognizerclassdisposetopic (no caption;) method in a derived class, call the frlrfmicrosoftstylusinputgesturerecognizerclassdisposetopic (no caption;) method of the base class so that the object's resources are properly released.

When the frlrfmicrosoftstylusinputgesturerecognizerclassdisposetopic (no caption;) parameter is true, this method releases all resources held by any managed objects that this object references. This method invokes the Dispose Leave Site method of each referenced object.

Note: to InheritorsDispose can be called multiple times by other objects. When overriding frlrfmicrosoftstylusinputgesturerecognizerclassdisposetopic (no caption;) , be careful not to reference objects that have been previously disposed of in an earlier call to Dispose. For more information about how to implement frlrfmicrosoftstylusinputgesturerecognizerclassdisposetopic (no caption;) , see Implementing a Dispose Method Leave Site.

For more information about garbage collection, see Programming for Garbage Collection Leave Site.

Examples

This Microsoft Visual C#® .NET example is a snippet from a form's Closed Leave Site event handler, which disables the RealTimeStylus, GestureRecognizer, and DynamicRenderer objects, empties the RealTimeStylus objects' queues, and calls the Dispose method of the objects.

[C#]using Microsoft.Ink;
using Microsoft.StylusInput;
using Microsoft.StylusInput.PluginData;

// ...

// Declare the RealTimeStylus objects, the GestureRecognizer plugin,
// and the DynamicRenderer plug-in.
private Microsoft.StylusInput.RealTimeStylus thePrimaryRealTimeStylus = null;
private Microsoft.StylusInput.RealTimeStylus theSecondaryRealTimeStylus = null;
private Microsoft.StylusInput.GestureRecognizer theGestureRecognizer = null;
private Microsoft.StylusInput.DynamicRenderer theDynamicRenderer = null;

// ...

// The form's Closed event handler.
private void theForm_Closed(object sender, System.EventArgs e)
{
    // Disable the RealTimeStylus and the appropriate plug-ins.
    this.thePrimaryRealTimeStylus.Enabled = false;
    this.theGestureRecognizer.Enabled = false;
    this.theDynamicRenderer.Enabled = false;

    // Empty the RealTimeStylus queues
    this.thePrimaryRealTimeStylus.ClearStylusQueues();
    this.theSecondaryRealTimeStylus.ClearStylusQueues();

    // Dispose of the the RealTimeStylus objects and appropriate plug-ins.
    this.thePrimaryRealTimeStylus.Dispose();
    this.thePrimaryRealTimeStylus = null;
    this.theSecondaryRealTimeStylus.Dispose();
    this.theSecondaryRealTimeStylus = null;
    this.theDynamicRenderer.Dispose();
    this.theDynamicRenderer = null;
    this.theGestureRecognizer.Dispose();
    this.theGestureRecognizer = null;
}