DbDataReader.DisposeAsync DbDataReader.DisposeAsync DbDataReader.DisposeAsync DbDataReader.DisposeAsync Method

定义

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

public:
 virtual System::Threading::Tasks::ValueTask DisposeAsync();
public virtual System.Threading.Tasks.ValueTask DisposeAsync ();
abstract member DisposeAsync : unit -> System.Threading.Tasks.ValueTask
override this.DisposeAsync : unit -> System.Threading.Tasks.ValueTask
Public Overridable Function DisposeAsync () As ValueTask

返回

表示异步操作的 ValueTaskA ValueTask representing the asynchronous operation.

实现

注解

使用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.

此异步方法的默认实现将委托给其同步对应项,并返回ValueTask已完成的,这可能会阻止调用线程。The default implementation of this asynchronous method delegates to its synchronous counterpart and returns a completed ValueTask, potentially blocking the calling thread.

支持异步编程的数据访问接口应使用异步 i/o 操作来重写默认实现。Data providers that support asynchronous programming should override the default implementation using asynchronous I/O operations.

适用于