Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AsyncContext.Run(Func<Task>) retrying tasks that throw exceptions? #30

Closed
stephendrew opened this issue Sep 14, 2015 · 1 comment
Closed
Assignees

Comments

@stephendrew
Copy link

Hi Stephen,

Thanks for your great library!

I have a simple console app that uses AsyncContext.Run(Func) to run a task. If the task throws an exception, it seems to keep retrying the task over and over again....

Am I doing something stupid?

Cheers,
Steve

    class Program
    {
        static void Main(string[] args)
        {
            AsyncContext.Run(() => RunAsync());
        }

        static async Task RunAsync()
        {
            await DoSomethingAsync();

            throw new Exception();
        }

        static async Task DoSomethingAsync()
        {
            await Task.Delay(1000);
        }
    }
@StephenCleary
Copy link
Owner

I believe what you're seeing is actually due to the way the Visual Studio debugger acts with top-level exceptions. It is weird behavior (and quite possibly a bug), but if you run your app outside the debugger you'll see that it's not actually retrying the code. VS is just re-showing the exception for some unfathomable reason.

In particular, you'll see the same behavior with this code:

static void Main(string[] args)
{
    throw new Exception();
}

@StephenCleary StephenCleary self-assigned this Jun 30, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants