microsoft/teams.net

Public

mirrored fromhttps://github.com/microsoft/teams.netAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
v2.0.0-preview.5

Branches

Tags

  • No tags available.
0Branches0Tags
Go to file
Add file
Code

Clone

HTTPS

Download ZIP

Libraries/Microsoft.Teams.Common/Extensions/TaskExtensions.cs

22lines · modecode

1namespace Microsoft.Teams.Common.Extensions;
2
3public static class TaskExtensions
4{
5 public static async Task<T> Retry<T>(this Task<T> task, int max = 3, int delay = 200)
6 {
7 try
8 {
9 return await task.ConfigureAwait(false);
10 }
11 catch (Exception ex)
12 {
13 if (max > 0)
14 {
15 await Task.Delay(delay);
16 return await task.Retry(max - 1, delay * 2).ConfigureAwait(false);
17 }
18
19 throw new Exception(ex.Message, ex);
20 }
21 }
22}