I have a class that tries to get information from web service few times:

```
public TResult Try(Func<TResult> func, int maxRetries)
{
    TResult returnValue = default(TResult);
    int numTries = 0;
    bool succeeded = false;

    while (numTries < maxRetries)
    {
        try
        {
            returnValue = func();
            succeeded = true;
        }
        catch (Exception ex)
        {
            Log(ex,numTries);
        }
        finally
        {
            numTries++;
        }
        if (succeeded)
        {
            return returnValue;
        }
        else
        {
            if (numTries == maxRetries)
            {
                 //ask user what to do
            }
        }
  }

```

Now after 'if (numTries == maxRetries)' user will be able to chose if he wants to continue trying to get data from web service or cancel.
I want to just open new form when user cancels and stop executing method that called above method. I can't just return null or new object because the method that run this retrier will continue to work and in many cases cause problems.

So basically this looks like this:

```
someValue = retry.Try(() => webService.method(),maxRetries));
//if user canceled after app wasn't able to get data stop execution as already another form is opened

```

I could of course check if returned value was null like:

```
someValue = retry.Try(()=>webService.method(),maxRetries));
if (someValue == null) 
return;

```

But this would mean a lot of changes in the code and I want to avoid it and it would be best if I could do it from Try method.