public void Close()
        {
            if (this.State == ConnectionState.Closed)
            {
                return;
            }

            this.CheckConsistency();

            if (this.Info.AuthType == AuthenticationType.PrivateKey)
            {
                PrivateKeyStorage.Delete(this.Info.PrivateKeyData);
            }

            try
            {
                if (!this.process.HasExited)
                {
                    this.State = ConnectionState.Closing;
                    this.process.Kill();
                }
            }
            // ReSharper disable once EmptyGeneralCatchClause
            catch (Exception)
            {
            }

            this.State = ConnectionState.Closed;
        }
        private void FindAccessGrantedMessage(string text)
        {
            if (text.Contains(@"Access granted"))
            {
                if (this.Info.AuthType == AuthenticationType.PrivateKey)
                {
                    PrivateKeyStorage.Delete(this.Info.PrivateKeyData);
                }

                this.PublishMessage(
                    MessageSeverity.Debug,
                    string.Format("Access granted called: {0}", this.Info.DisplayText));

                var shellWontBeStarted = string.IsNullOrWhiteSpace(this.Info.RemoteCommand);
                if (shellWontBeStarted)
                {
                    this.timer = new Timer(
                        delegate
                    {
                        this.PublishMessage(
                            MessageSeverity.Debug,
                            string.Format("Delegate called: {0}", this.Info.DisplayText));
                        this.State = ConnectionState.Open;
                    },
                        null,
                        1500,
                        Timeout.Infinite);
                }
            }
        }