清理存储的上下文。
语法
virtual VOID CleanupStoredContext(
VOID
) = 0;
参数
此方法不采用参数。
注解
此方法的行为取决于实现。 应将以下信息用作指南,但并非所有方案都正确:
某些实现在 方法期间
CleanupStoredContext执行空操作。某些实现调用
delete``this当前 IHttpStoredContext 指针。某些实现使用内部引用计数,并在每次调用
CleanupStoredContext期间递减内部引用计数。 如果引用计数为 0,则这些实现程序立即调用delete``this当前IHttpStoredContext。
实现者须知
IHttpStoredContext 实现者应创建 protected 或 private``virtual 析构函数,因为 IHttpStoredContext 指针不应向下转换到其最特定的类以删除。 相反,这些实现器的删除应由每个指针在内部控制,并在调用 CleanupStoredContext期间进行处理。
对调用者的说明
方法CleanupStoredContext只应在指针上调用一IHttpStoredContext次,因为某些实现在调用 时CleanupStoredContext会调用 delete``this 。 对大多数IHttpStoredContext指针调用CleanupStoredContext多次会引发访问冲突异常或内存中的数据损坏。
示例
下面的代码示例演示如何创建名为 IHttpStoredContextMyStoredContext 的类,以及如何在内部控制指针的 MyStoredContext 删除。 MyStoredContext 仅实现析 private 构函数,并在调用 方法时 CleanupStoredContext 调用该析构函数。
// The MyStoredContext class implements the IHttpStoredContext
// interface and demonstrates one possible solution for
// implementing the CleanupStoredContext method.
class MyStoredContext : public IHttpStoredContext
{
public:
// The MyStoredContext method is the public
// constructor for the MyStoredContext class.
MyStoredContext()
{
}
// The CleanupStoredContext method must be implemented
// by non-abstract classes that implement the
// IHttpStoredContext interface. This method
// calls delete this.
virtual void CleanupStoredContext(VOID)
{
delete this;
}
private:
// The MyStoredContext method is the private virtual
// destructor for the MyStoredContext class.
virtual ~MyStoredContext()
{
}
};
要求
| 类型 | 说明 |
|---|---|
| 客户端 | - Windows Vista 上的 IIS 7.0 - Windows 7 上的 IIS 7.5 - Windows 8 上的 IIS 8.0 - Windows 10 上的 IIS 10.0 |
| 服务器 | - Windows Server 2008 上的 IIS 7.0 - Windows Server 2008 R2 上的 IIS 7.5 - Windows Server 2012 上的 IIS 8.0 - Windows Server 2012 R2 上的 IIS 8.5 - Windows Server 2016 上的 IIS 10.0 |
| 产品 | - IIS 7.0、IIS 7.5、IIS 8.0、IIS 8.5、IIS 10.0 - IIS Express 7.5、IIS Express 8.0、IIS Express 10.0 |
| Header | Httpserv.h |