title: How to wait for WCF proxy client to be ready?
body: <p>I'm trying to figure out how to get my WCF proxy class to wait to be ready before proceeding, or allowing calls to the service.</p>
  
  <p>I tried something like this:</p>
  
  <pre><code>    _proxy = new WCFBlackjack(new NetNamedPipeBinding(), new EndpointAddress("net.pipe://localhost/blackjack/IWCFBlackjack"));
  
      while(!_proxy.State.Equals(CommunicationState.Opened)) {
          if(!_proxy.State.Equals(CommunicationState.Opening)) {
              try {
                  _proxy.Open();
              } catch(EndpointNotFoundException enfe) {
                  /* ... */
              }
          }
          System.Threading.Thread.Sleep(1);
      }
  </code></pre>
  
  <p>But obviously that doesn't work otherwise I wouldn't be here. At first it seems to work but the ChannelFactory throws an InvalidOperationException on the open statement.</p>
  
  <p>I'm new to WCF and maybe I'm thinking too much along the lines of something that is Sockets-esque but I would like my client to continue to retry until the endpoint becomes available or can be found, and somehow fire an on-connected event or something along those lines.</p>