DbDataReader.Dispose 方法

定义

释放 DbDataReader 使用的资源并调用 Close()Releases the resources used by the DbDataReader and calls Close().

重载

Dispose()

释放 DbDataReader 类的当前实例所使用的所有资源。Releases all resources used by the current instance of the DbDataReader class.

Dispose(Boolean)

释放由 DbDataReader 占用的非托管资源,还可以另外再释放托管资源。Releases the unmanaged resources used by the DbDataReader and optionally releases the managed resources.

Dispose()

释放 DbDataReader 类的当前实例所使用的所有资源。Releases all resources used by the current instance of the DbDataReader class.

public:
 virtual void Dispose();
public void Dispose ();
abstract member Dispose : unit -> unit
override this.Dispose : unit -> unit
Public Sub Dispose ()

实现

注解

使用完成后,调用 DisposeDisposeAsync DbDataReaderCall Dispose or DisposeAsync when you've finished using the DbDataReader. 调用这些方法之一会使 DbDataReader 处于不可用状态。Calling one of these methods leaves the DbDataReader in an unusable state. 释放后,必须释放对的所有引用, DbDataReader 这样垃圾回收器才能收回占用的内存 DbDataReaderAfter disposing, you must release all references to the DbDataReader so the garbage collector can reclaim the memory that the DbDataReader was occupying.

有关详细信息,请参阅 清理非托管资源实现 Dispose 方法For more information, see Cleaning Up Unmanaged Resources and Implementing a Dispose Method.

备注

在释放对的最后一个引用之前,始终释放 DbDataReaderAlways dispose before you release your last reference to the DbDataReader. 否则,在垃圾回收器调用 DbDataReader 对象的 Finalize 方法之前,该对象正在使用的资源不会被释放。Otherwise, the resources it is using will not be freed until the garbage collector calls the DbDataReader object's Finalize method.

另请参阅

Dispose(Boolean)

释放由 DbDataReader 占用的非托管资源,还可以另外再释放托管资源。Releases the unmanaged resources used by the DbDataReader and optionally releases the managed resources.

protected:
 virtual void Dispose(bool disposing);
protected virtual void Dispose (bool disposing);
abstract member Dispose : bool -> unit
override this.Dispose : bool -> unit
Protected Overridable Sub Dispose (disposing As Boolean)

参数

disposing
Boolean

若要释放托管资源和非托管的资源,则为 true;若要仅释放非托管资源,则为 falsetrue to release managed and unmanaged resources; false to release only unmanaged resources.

注解

此方法调用 CloseThis method calls Close.

另请参阅

适用于