Наследование: Library.ManagerBase
        protected override void Dispose(bool disposing)
        {
            if (_disposed) return;
            _disposed = true;

            if (disposing)
            {
                if (_samManager != null) _samManager.Dispose();
                _samManager = null;
            }
        }
        private void WatchThread()
        {
            var checkSamStopwatch = new Stopwatch();
            checkSamStopwatch.Start();

            for (;;)
            {
                Thread.Sleep(1000);
                if (this.State == ManagerState.Stop) return;

                if (!checkSamStopwatch.IsRunning || checkSamStopwatch.Elapsed.TotalSeconds >= 30)
                {
                    checkSamStopwatch.Restart();

                    if ((_samManager == null || !_samManager.IsConnected)
                        || _oldSamBridgeUri != this.SamBridgeUri)
                    {
                        string i2pUri = null;

                        try
                        {
                            var match = _regex.Match(this.SamBridgeUri);
                            if (!match.Success) throw new Exception();

                            if (match.Groups[1].Value == "tcp")
                            {
                                {
                                    if (_samManager != null)
                                    {
                                        _samManager.Dispose();
                                        _samManager = null;
                                    }

                                    var host = match.Groups[2].Value;
                                    var port = int.Parse(match.Groups[3].Value);

                                    _samManager = new SamManager(host, port, "Amoeba");
                                }

                                var base32Address = _samManager.Start();

                                if (base32Address != null)
                                {
                                    i2pUri = string.Format("i2p:{0}", base32Address);
                                }
                            }
                        }
                        catch (Exception)
                        {
                            if (_samManager != null) _samManager.Dispose();
                        }

                        lock (_thisLock)
                        {
                            if (i2pUri != _settings.I2pUri)
                            {
                                if (this.RemoveUri(_settings.I2pUri))
                                    Log.Information(string.Format("Remove Node uri: {0}", _settings.I2pUri));
                            }

                            _settings.I2pUri = i2pUri;

                            if (_settings.I2pUri != null)
                            {
                                if (this.AddUri(_settings.I2pUri))
                                    Log.Information(string.Format("Add Node uri: {0}", _settings.I2pUri));
                            }

                            _oldSamBridgeUri = this.SamBridgeUri;
                        }
                    }
                }
            }
        }
        public override void Stop()
        {
            lock (_stateLock)
            {
                lock (_thisLock)
                {
                    if (this.State == ManagerState.Stop) return;
                    _state = ManagerState.Stop;
                }

                _watchThread.Join();
                _watchThread = null;

                if (_samManager != null) _samManager.Dispose();
                _samManager = null;

                lock (_thisLock)
                {
                    if (_settings.I2pUri != null)
                    {
                        if (this.RemoveUri(_settings.I2pUri))
                            Log.Information(string.Format("Remove Node uri: {0}", _settings.I2pUri));
                    }
                    _settings.I2pUri = null;
                }
            }
        }