public bool Initialize(Uri serverAddressUri)
        {
            lock (this)
            {
                EndpointAddress serverAddress = new EndpointAddress(serverAddressUri);

                try
                {
                    // If you get a configuration exception here in debug mode, just *ignore it* (disable it from Debug >> Exceptions),
                    // normal execution exceptions is just one more of the WCFs excellent features:
                    // see more here: http://ari-techno.blogspot.com/2008/08/this-element-is-not-currently.html

                    _channelFactory = new DuplexChannelFactory <IMessageContainerTransport>(
                        this, MessageContainerTransportServer.CreateBinding(), serverAddress);
                }
                catch (ConfigurationErrorsException)
                {// This is a dummy catch, just to shut the debugger up.
                }

                lock (Clients)
                {
                    if (Clients.Contains(this) == false)
                    {
                        Clients.Add(this);

                        if (Clients.Count == 1)
                        {// We are the single new starting client, fire the connection monitoring thread.
                            GeneralHelper.FireAndForget(ConnectionMonitorThread);
                        }
                    }
                }
            }

            return(true);
        }
 public void ChangeServerAddressUri(Uri serverAddressUri)
 {
     lock (this)
     {
         EndpointAddress serverAddress = new EndpointAddress(serverAddressUri);
         _channelFactory = new DuplexChannelFactory <IMessageContainerTransport>(
             this, MessageContainerTransportServer.CreateBinding(), serverAddress);
         _proxyServerInterface = null;
     }
 }