DbDataReader.Dispose DbDataReader.Dispose DbDataReader.Dispose DbDataReader.Dispose Method

定义

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

重载

Dispose() Dispose() Dispose() Dispose()

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

Dispose(Boolean) Dispose(Boolean) Dispose(Boolean) Dispose(Boolean)

释放由 DbDataReader 使用的托管资源,还可以选择释放非托管资源。Releases the managed resources used by the DbDataReader and optionally releases the unmanaged resources.

Dispose() Dispose() Dispose() 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 ()

实现

注解

使用Dispose 完成后DisposeAsync ,调用或。 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.

备注

在释放对的DbDataReader最后一个引用之前,始终释放。Always 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) Dispose(Boolean) Dispose(Boolean) Dispose(Boolean)

释放由 DbDataReader 使用的托管资源,还可以选择释放非托管资源。Releases the managed resources used by the DbDataReader and optionally releases the unmanaged 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 Boolean Boolean Boolean

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

注解

此方法调用 CloseThis method calls Close.

另请参阅

适用于