public T Handle <T>(Func <T> tryFunc, Action <Exception> catchFunc = null, Action finallyFunc = null)
        {
            T   result   = default;
            var attempts = 0;

            var success = false;

            while (!success && attempts < Options.MaximumAttempts)
            {
                result = TryCatchHandler.Handle(() =>
                {
                    var value = tryFunc();
                    success   = true;
                    return(value);
                }, ex =>
                {
                    catchFunc?.Invoke(ex);
                    Thread.Sleep(Options.Timeout);
                    attempts++;
                }, finallyFunc, catchExceptionTypesArray: Options.ExceptionTypes.ToArray());
            }

            return(result);
        }
 public Task <T> HandleAsync(Func <Task <T> > tryFunc, Func <Exception, Task> catchFunc, Func <Task> finallyFunc = null, params Type[] catchExceptionTypesArray)
 {
     return(TryCatchHandler.HandleAsync(tryFunc, catchFunc, finallyFunc, catchExceptionTypesArray: catchExceptionTypesArray));
 }
 public T Handle(Func <T> tryFunc, Action <Exception> catchFunc, Action finallyAction = null, params Type[] catchExceptionTypesArray)
 {
     return(TryCatchHandler.Handle(tryFunc, catchFunc, finallyAction, catchExceptionTypesArray: catchExceptionTypesArray));
 }