title: Generic async Retry with Timeout function in C#
body: <p>I have hundreds of calls to various external API's that I want to wrap in a generic async function that is capable of doing retries and handling timeouts.</p>
  
  <p>Basically, I think I need to implement something like this function call:</p>
  
  <pre><code>await Retry(()=&gt;someFunctionAsync(doWorkParams, new CancellationToken()), retryCount, timeout);
  </code></pre>
  
  <p>How do I define such Retry function?  Also, how do I call this function from Sync code, as a ton of my calls are housed in the sync methods?</p>