Share via


GestureRecognizer.Dispose Method

Releases resources used by the GestureRecognizer object.

Namespace:  Microsoft.StylusInput
Assembly:  Microsoft.Ink (in Microsoft.Ink.dll)

Syntax

'Declaration
Public Sub Dispose
'Usage
Dim instance As GestureRecognizer

instance.Dispose()
public void Dispose()
public:
virtual void Dispose() sealed
public final function Dispose()

Implements

IDisposable.Dispose()

Remarks

Calling the Dispose method allows the resources used by the object to be reallocated for other purposes. For more information about garbage collection, see Programming for Garbage Collection.

Warning

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 the Dispose method 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.

Examples

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

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 appropriate plug-ins.
    this.theGestureRecognizer.Enabled = false;
    this.theDynamicRenderer.Enabled = false;
    this.theFilterPlugin.Enabled = false;

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

    // Disable the RealTimeStylus.
    this.thePrimaryRealTimeStylus.Enabled = false;

    // 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;
}

Platforms

Windows 7, Windows Vista, Windows XP SP2, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Version Information

.NET Framework

Supported in: 3.0

See Also

Reference

GestureRecognizer Class

GestureRecognizer Members

Microsoft.StylusInput Namespace