| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091 | using System;using System.Threading;namespace Renci.SshNet{    /// <summary>    /// Provides functionality for local port forwarding    /// </summary>    public partial class ForwardedPortLocal : ForwardedPort, IDisposable    {        private EventWaitHandle _listenerTaskCompleted;        /// <summary>        /// Starts local port forwarding.        /// </summary>        public override void Start()        {            this.InternalStart();        }        /// <summary>        /// Stops local port forwarding.        /// </summary>        public override void Stop()        {            base.Stop();            this.InternalStop();        }        partial void InternalStart();        partial void InternalStop();        partial void ExecuteThread(Action action);        #region IDisposable Members        private bool _isDisposed = false;        /// <summary>        /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged ResourceMessages.        /// </summary>        public void Dispose()        {            Dispose(true);            GC.SuppressFinalize(this);        }        /// <summary>        /// Releases unmanaged and - optionally - managed resources        /// </summary>        /// <param name="disposing"><c>true</c> to release both managed and unmanaged resources; <c>false</c> to release only unmanaged ResourceMessages.</param>        protected virtual void Dispose(bool disposing)        {            // Check to see if Dispose has already been called.            if (!this._isDisposed)            {                // If disposing equals true, dispose all managed                // and unmanaged ResourceMessages.                if (disposing)                {                    // Dispose managed ResourceMessages.                    if (this._listenerTaskCompleted != null)                    {                        this._listenerTaskCompleted.Dispose();                        this._listenerTaskCompleted = null;                    }                }                // Note disposing has been done.                _isDisposed = true;            }        }        /// <summary>        /// Releases unmanaged resources and performs other cleanup operations before the        /// <see cref="ForwardedPortLocal"/> is reclaimed by garbage collection.        /// </summary>        ~ForwardedPortLocal()        {            // Do not re-create Dispose clean-up code here.            // Calling Dispose(false) is optimal in terms of            // readability and maintainability.            Dispose(false);        }        #endregion    }}
 |