title: Best practices for converting WCF calls to async WCF calls
body: <p>I am running into issues when trying to convert all my normal WCF calls to async WCF calls.  I'm finding I have a refactor a lot of code and not sure exactly how to do it.   I have used the method that I found <a href="https://stackoverflow.com/questions/537786/calling-wcf-service-asyncronously-in-a-loop">here</a> but running into issues where I need things to happen in order.  </p>
  
  <pre><code>private void btnSave_Click(object sender, RoutedEventArgs e)
  {
  
    List&lt;Item&gt; itemList = GetList();
    foreach(Item i in itemList)
    {
      DoSomeWork(i);
  
      if(i.SomeID == 0)
      {      
         DoSomeMoreWork(i);  
      }
  
      UpdateRecord(i)  // this can't execute until the above code is complete
  
    }
  }
  
  private void DoSomeWork(Item i)
  {
    // call async method
  }
  
  private void DoSomeMoreWork(i)
  {
    // call async method
  }
  
  private void UpdateRecord(item i)
  {
    // call async method
  }
  </code></pre>
  
  <p>What is the best way to refactor code to work in an asyncronous way, or do I need to completely rethink my logic?  Do I really have to insert counters and switches everywhere to make sure certain things are done before other things execute?</p>
  
  <p>EDIT:  The reason I'm doing this is in the next couple months, we are converting this WPF application to Silverlight, which requires async calls.  So I'm trying to convert our regular WCF calls to async in preparation.  I'm finding it requires a different way of thinking.</p>