Dispose() публичный Метод

Releases all resources used by the BytesRoad.Net.Sockets.SocketEx.
Call Dispose when you are finished using the BytesRoad.Net.Sockets.SocketEx. The Dispose method leaves the SocketEx in an unusable state. After calling Dispose, you must release all references to the SocketEx so the garbage collector can reclaim the memory that the SocketEx was occupying.
public Dispose ( ) : void
Результат void
Пример #1
0
        /// <summary>
        /// Releases the unmanaged resources used by the
        /// <see cref="BytesRoad.Net.Sockets.NetworkStreamEx"/>
        /// and optionally releases the managed resources.
        /// </summary>
        /// <param name="disposing">
        /// <b>true</b> to release both managed and unmanaged resources;
        /// <b>false</b> to release only unmanaged resources.
        /// </param>
        /// <remarks>
        /// This method is called by the public
        /// <see cref="BytesRoad.Net.Sockets.NetworkStreamEx.Dispose">Dispose()</see>
        /// method and the
        /// <see cref="BytesRoad.Net.Sockets.NetworkStreamEx.Finalize">Finalize</see>
        /// method. <b>Dispose()</b> invokes the protected
        /// <b>Dispose(Boolean)</b>
        /// method with the <i>disposing</i> parameter set to <b>true</b>.
        /// <b>Finalize</b> invokes <b>Dispose</b> with <i>disposing</i>
        /// set to <b>false</b>.
        /// When the <i>disposing</i> parameter is <b>true</b>,
        /// this method releases all resources held by any managed
        /// objects that this <b>NetworkStreamEx</b> references.
        /// This method invokes the <b>Dispose()</b> method of each
        /// referenced object.
        ///
        /// <note>
        /// If the <b>NetworkStreamEx</b> owns the underlying <see cref="BytesRoad.Net.Sockets.SocketEx"/>
        /// the <b>Dispose</b> method will call <see cref="BytesRoad.Net.Sockets.SocketEx.Close"/>
        /// method to release <b>SocketEx</b> object used for network communications.
        /// </note>
        ///
        /// </remarks>
        protected virtual void mDispose(bool disposing)
        {
            lock (this)
            {
                if (!_disposed)
                {
                    _disposed = true;
                    if (disposing)
                    {
                    }

                    if (_ownsSocket)
                    {
                        _socket.Dispose();
                    }
                }
            }
        }