title: Is it possible for a WCF channel to fault right after checking the state (single thread)?
body: <p>I have been handing the closing and aborting of channels this way:</p>
  
  <pre><code>public async Task&lt;MyDataContract&gt; GetDataFromService()
  {
      IClientChannel channel = null;
      try
      {
          IMyContract contract = factory.CreateChannel(address);
          MyDataContract returnValue = await player.GetMyDataAsync();
          channel = (IClientChannel);
          return returnValue;
      } 
      catch (CommunicationException)
      {
         // ex handling code
      } 
      finally
      {
          if (channel != null)
          {
              if (channel.State == CommunicationState.Faulted)
              {
                  channel.Abort();
              }
              else
              {
                  channel.Close();
              }
           }
      }
  }
  </code></pre>
  
  <p>Assume only a single thread uses the channel.  How do we know the channel will not fault right after checking the state?  If such a thing were to happen, the code would try to Close() and Close() will throw an exception in the finally block.  An explanation about why this is safe/unsafe and examples of a better, safer way would be appreciated.</p>