title: How can I check connection is still valid for Silverlight client using net.tcp for duplex?
body: <p>I'm putting together a WCF service using net.tcp and netTcpBinding to get duplex comms with my Silverlight client.  I call into the service from the Silverlight app and the service calls out to another server, passing it a callback method in the WCF service class.  The remote server calls back several times and each time it does, the WCF service uses the callbackchannel to send the data to the Silverlight client.  It all works nicely most of the time.</p>
  
  <p>If the user puts in a big request, I get a TimeoutException after a large number of callbacks have already worked.  (Clearly, there's some work to do elsewhere to prevent this but I'd like to robustify the service, first.)</p>
  
  <p>I was expecting to do some kind of 'if (client.ConnectionState == faulted)' check before trying to call back to the Silverlight client but I can't seem to find the object that holds the state of the connection.  Is there one?  Am I approaching this from the wrong side?</p>
  
  <p>This is my first venture into a service net.tcp and duplex.  I just moved house and my WCF bible is still in a box.  Somewhere.  :-)  So, I can't do my usual background reading.</p>
  
  <p>Any pointers would be gratefully received.  Here's some bare code in case my description is too soupy:</p>
  
  <pre><code>    private IActiveDirectoryClient client;
      private AsyncSearchRunner runner;
  
      public void Search(Request request)
      {
          this.client = OperationContext.Current.GetCallbackChannel&lt;IActiveDirectoryClient&gt;();
  
          runner = new AsyncSearchRunner();
          runner.Run(request.SearchRoot, request.SearchFilter, request.PageSize, 
              System.DirectoryServices.Protocols.SearchScope.Subtree, SendObjects);
      }
  
      private void SendObjects(List&lt;DirectoryObject&gt; items)
      {
          Response response = new Response();
          response.DirectoryObjects = items.ToArray();
  
          client.SendResponse(response);
      }
  </code></pre>