TcpClient.IDisposable.Dispose 方法
定义
virtual void System.IDisposable.Dispose() = IDisposable::Dispose;
void IDisposable.Dispose ();
abstract member System.IDisposable.Dispose : unit -> unit
override this.System.IDisposable.Dispose : unit -> unit
Sub Dispose () Implements IDisposable.Dispose
实现
注解
使用完后,调用 TcpClient IDisposable。Call IDisposable.Dispose when you are finished using the TcpClient. IDisposable 方法会使 TcpClient 处于不可用状态。The IDisposable.Dispose method leaves the TcpClient in an unusable state. 调用 IDisposable 之后,必须释放对的所有引用, TcpClient 这样垃圾回收器才能收回占用的内存 TcpClient 。After calling IDisposable.Dispose, you must release all references to the TcpClient so the garbage collector can reclaim the memory that the TcpClient was occupying. 有关详细信息,请参阅 清理非托管资源 和 实现 Dispose 方法。For more information, see Cleaning Up Unmanaged Resources and Implementing a Dispose Method.
备注
在释放对的最后一个引用之前,请始终调用 IDisposable TcpClient 。Always call IDisposable.Dispose before you release your last reference to the TcpClient. 否则,在垃圾回收器调用 TcpClient 对象的 Finalize 方法之前,不会释放它所使用的资源。Otherwise, the resources it is using will not be freed until the garbage collector calls the TcpClient object's Finalize method.