public void Dispose()
        {
            if (this.encodingServer != null)
            {
                this.encodingServer.Stop();
                this.encodingServerThread.Join();

                this.encodingServer = null;
                this.encodingServerThread = null;
            }

            if (this.discoveryServer != null)
            {
                this.discoveryServer.Close();
                this.discoveryServerThread.Join();

                this.discoveryServer = null;
                this.discoveryServerThread = null;
            }
        }
        public bool Initialize(ILogger logger, ConfigProviderBase configProvider)
        {
            this.logger = logger;

            try
            {
                this.discoveryServer = new DiscoveryServer();
            }
            catch (Exception e)
            {
                this.logger.Log("Error creating discovery server: " + e);
                return false;
            }
            this.discoveryServerThread = new Thread(new ThreadStart(() =>
            {
                try
                {
                    this.discoveryServer.Run();
                }
                catch (Exception e)
                {
                    this.logger.Log("Error running discovery server: " + e);
                }
            }));

            try
            {
                this.encodingServer = new EncodingServer();
            }
            catch (Exception e)
            {
                this.logger.Log("Error creating encoding server: " + e);
                return false;
            }
            this.encodingServerThread = new Thread(new ThreadStart(() =>
            {
                try
                {
                    this.encodingServer.Run();
                }
                catch (Exception e)
                {
                    this.logger.Log("Error running encoding server: " + e);
                }
            }));

            this.discoveryServerThread.Start();
            this.encodingServerThread.Start();

            this.logger.Log("Service started...");

            return true;
        }