AsyncDolls.AsyncDollsScript.Retrier C# (CSharp) Method

Retrier() static private method

static private Retrier ( Func next ) : System.Threading.Tasks.Task
next Func
return System.Threading.Tasks.Task
        static async Task Retrier(Func<Task> next)
        {
            ExceptionDispatchInfo exceptionDispatchInfo = null;
            for (int i = 0; i < 3; i++)
            {
                try
                {
                    await next();
                    exceptionDispatchInfo = null;
                    break;
                }
                catch (Exception ex)
                {
                    exceptionDispatchInfo = ExceptionDispatchInfo.Capture(ex);
                }
            }

            exceptionDispatchInfo?.Throw();
        }
    }