GestureRecognizer.Dispose 方法

释放 GestureRecognizer 对象所使用的资源。

命名空间:  Microsoft.StylusInput
程序集:  Microsoft.Ink(在 Microsoft.Ink.dll 中)

语法

声明
Public Sub Dispose
用法
Dim instance As GestureRecognizer

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

实现

IDisposable.Dispose()

备注

通过调用 Dispose 方法可以重新分配对象所使用的资源以用于其他目的。有关垃圾回收的更多信息,请参见 Programming for Garbage Collection(垃圾回收编程)。

警告

为避免内存泄漏,必须在 Microsoft Windows XP Tablet PC Edition 软件开发工具包 (SDK) 中已附加事件处理程序的任何对象或控件超出范围之前,对该对象或控件显式调用此方法。

对于 Tablet PC SDK 中定义了 Dispose 方法的任何类,应在不再需要该类时手动释放该类的每个实例。释放这些对象可提高应用程序的性能。

示例

此 C# 示例是窗体的 Closed 事件处理程序中的代码段,它禁用 RealTimeStylusGestureRecognizerDynamicRenderer 对象,清空 RealTimeStylus 对象的队列,并调用对象的 Dispose 方法。

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

平台

Windows Vista, Windows XP SP2, Windows Server 2003

.NET Framework 和 .NET Compact Framework 并不是对每个平台的所有版本都提供支持。有关支持的版本的列表,请参见.NET Framework 系统要求

版本信息

.NET Framework

受以下版本支持:3.0

另请参见

参考

GestureRecognizer 类

GestureRecognizer 成员

Microsoft.StylusInput 命名空间