Beispiel #1
0
        /// <summary>
        /// Dispose(bool disposing) executes in two distinct scenarios.
        /// If disposing equals true, the method has been called directly
        /// or indirectly by a user's code. Managed and unmanaged resources
        /// can be disposed.
        /// If disposing equals false, the method has been called by the
        /// runtime from inside the finalizer and you should not reference
        /// other objects. Only unmanaged resources can be disposed.
        /// </summary>
        protected virtual void Dispose(bool disposing)
        {
            // Check to see if Dispose has already been called.
            if (!this._disposed)
            {
                // If disposing equals true, dispose all managed
                // and unmanaged resources.
                if (disposing)
                {
                    // Dispose managed resources.
                    if (streamHost != null)
                    {
                        streamHost.Dispose();
                    }
                }

                // Call the appropriate methods to clean up
                // unmanaged resources here.
                streamHost       = null;
                threadStreamHost = null;

                // Note disposing has been done.
                _disposed = true;
            }
        }
Beispiel #2
0
        /// <summary>
        /// Initialse all objects, create new
        /// instances of all servers and cleanup
        /// objects when complete.
        /// </summary>
        /// <param name="create">Create a new instance.</param>
        /// <param name="serviceHostType">The service host type</param>
        private void Initialise(bool create, Type serviceHostType)
        {
            // Create new instances.
            if (create)
            {
                // Create a new file transfer host
                // with default configuration setting.
                streamHost = new NetTcpHost(serviceHostType);
            }
            else
            {
                // Dispose of all the servers.
                if (streamHost != null)
                {
                    streamHost.Dispose();
                }

                // Cleanup threads.
                threadStreamHost = null;
            }
        }