Partager via


RealTimeStylus.Dispose Method

RealTimeStylus.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 Dispose 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.

The RealTimeStylus object does not guarantee thread safety for the Dispose method. Avoid calling the Dispose method while other threads may be using the RealTimeStylus object.

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

Note: The RealTimeStylus object throws an exception if its frlrfmicrosoftstylusinputrealtimestylusclassdisposetopic (no caption;) method is called by any of its plug-ins from an IStylusSyncPlugin or IStylusAsyncPlugin interface method implementation.

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