RealTimeStylus.Dispose 方法
释放 RealTimeStylus 对象使用的所有资源。
命名空间: Microsoft.StylusInput
程序集: Microsoft.Ink(在 Microsoft.Ink.dll 中)
语法
声明
Public Sub Dispose
用法
Dim instance As RealTimeStylus
instance.Dispose()
public void Dispose()
public:
virtual void Dispose() sealed
public final void Dispose()
public final function Dispose()
实现
备注
通过调用 Dispose 方法可以重新分配对象所使用的资源以用于其他目的。
RealTimeStylus 对象不保证 Dispose 方法的线程安全。请避免在其他线程可能正在使用 RealTimeStylus 对象的同时调用 Dispose 方法。
警告
从 Microsoft Windows XP Tablet PC Edition 软件开发工具包 (SDK) 开始,必须在事件处理程序附加到的任何对象或控件超出范围之前,对该对象或控件显式调用 Dispose 方法。
对于 Tablet PC SDK 中定义了 Dispose 的任何类,应在不再需要该类时手动释放该类的每个实例。释放这些对象可提高应用程序的性能。
备注
如果来自 IStylusSyncPlugin 或 IStylusAsyncPlugin 接口方法实现的 RealTimeStylus 对象的任何插件调用该对象的 Dispose 方法,则该对象将引发异常。
示例
此 Microsoft Visual C# .NET 示例是窗体的 Closed 事件处理程序中的代码段,它禁用 RealTimeStylus、GestureRecognizer 和 DynamicRenderer 对象,清空 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