title: Thread.Sleep or Task.Delay in a synchronous method with both a sync and async caller
body: <p>I have a synchronous method:</p>
  
  <pre><code>public void DoStuff() {  
      DoThings(); 
      GraphClient.SetExtendedProperty(user, propertyName, value);     // this method occasionally throws an exception
      DoOtherThings();
  }
  </code></pre>
  
  <p><code>Call3rdPartyMethod</code> makes a REST API call using the <a href="https://www.nuget.org/packages/Microsoft.Azure.ActiveDirectory.GraphClient/" rel="nofollow noreferrer">Azure Ad Graph Client API</a> which throws an exception if I try to set the value of an extended property on Active Directory and it isn't found.  This usually happens a new user is added to the directory and the Extension Properties feature hasn't extended the user schema before I want to set the values (it seems to take a few seconds).</p>
  
  <p>I replaced the SetExtendedProperty call with my own wrapper containing the call in a busy-wait loop thus:</p>
  
  <pre><code>public void TrySetProperty(GraphObject user, string propertyName, string value)
  {
  
     var exceptions = new List&lt;Exception&gt;();
  
     for (int retry = 0; retry &lt; 5; retry++)
     {
        try
        { 
            if (retry &gt; 0)
                Thread.Sleep(1000);
                GraphClient.SetExtendedProperty(user, propertyName, value);
        }
        catch (Exception ex)
        { 
            exceptions.Add(ex);
        }
     }
  
     throw new AggregateException(exceptions);
    }
  }
  </code></pre>
  
  <p>The issue is that I want to be able to call <code>TrySetProperty</code> from both a synchronous and asynchronous method:</p>
  
  <pre><code>public void DoStuff() {  
      DoThings(); 
      TrySetProperty(user, propertyName, value);
      DoOtherThings();
  }
  
  public Task DoOtherStuffAsync() {
      await DoAsyncThings();
      TrySetProperty(user, propertyName, value);
      await DoOtherAsyncThings();
  }
  </code></pre>
  
  <p>I can't change SetExtendedProperty to be asynchronous, and I'm concerned I shouldn't be using Thread.Sleep if i'm calling it from an asynchronous method - rather Task.Delay().  Can anyone advise?</p>