none
AggregateException being thrown while debugging RRS feed

  • Question

  • Hello,

    Please have a look at the following screen shot which shows an exception that keeps getting thrown every time I'm debugging some code and I wait too long:



    The error message is: "One or more errors occurred."

    The inner exception says: "A task was canceled."

    The code that throws the exception (an AggregateException) sends a request to a web API and throws the exception when it times out. It times out when I'm debugging the code in the API. Why? Obviously because when I'm debugging, I must take my time and it takes much longer to complete than when when I just let it run.

    When the exception is thrown, it completely throws me off and it's a real nuassance. As you can see, I mitigated the nuissance by wrapping the code that throws the exception in a try/catch block which in turn is wrapped in "#if DEBUG...#endif" directives. The try/catch block itself works but it still throws me off. For one thing, I still get a rude interruption from the exception. For another, when I hit F10 after the interruption, I'm not at the same place in my debugging that I was before the exception (for example, I'm part way through a foreach loop, the exception is thrown, I hit F10, I'm suddenly on the next iteration of the foreach loop). For a third thing, the response has lost its chance to be sent back to the browser.

    Is there some way of increasing the timeout or eliminating it all together?

    Thanks.
    Friday, January 12, 2018 2:50 PM

Answers

  • 120000 is 120,000 ticks. 10,000 ticks = 1 ms so you're asking to wait 12 ms.

    Use FromMinutes and set the value to 2 or (more commonly) FromSeconds and set the value to 120.


    Michael Taylor http://www.michaeltaylorp3.net

    Monday, January 15, 2018 5:28 PM
    Moderator

All replies

  • Timing out web calls while debugging is one of the costs of debugging. There is not much you can do about it short of increasing the time out.

    Since it appears you're using Httpclient to make the call then set the Timeout property to a higher value while in debug mode.


    Michael Taylor http://www.michaeltaylorp3.net

    Friday, January 12, 2018 2:55 PM
    Moderator
  • Timing out web calls while debugging is one of the costs of debugging. There is not much you can do about it short of increasing the time out.

    Since it appears you're using Httpclient to make the call then set the Timeout property to a higher value while in debug mode.


    Michael Taylor http://www.michaeltaylorp3.net

    Thanks CoolDad but it doesn't seem to like it when I do that.

    When I say client.timeout = timeSpan.fromTicks(120000), setting it to 2 minutes (default is 1 min 40 sec), and then it sends the request, it immediately throws an AggregateException. Doesn't seem to matter what I set the timeout to. Guess I'm stuck with 1 minute and 40 seconds.

    Monday, January 15, 2018 4:55 PM
  • 120000 is 120,000 ticks. 10,000 ticks = 1 ms so you're asking to wait 12 ms.

    Use FromMinutes and set the value to 2 or (more commonly) FromSeconds and set the value to 120.


    Michael Taylor http://www.michaeltaylorp3.net

    Monday, January 15, 2018 5:28 PM
    Moderator
  • 120000 is 120,000 ticks. 10,000 ticks = 1 ms so you're asking to wait 12 ms.

    Use FromMinutes and set the value to 2 or (more commonly) FromSeconds and set the value to 120.


    Michael Taylor http://www.michaeltaylorp3.net

    Oops, my bad. For some reason, I was thinking 1 tick = 1 ms. Trying the FromMinutes() method seems to work. Thanks for pointing me in the right direction.
    Thursday, January 18, 2018 4:46 PM
  • Hi,

    If your question is answered then please mark one or more posts as answered so anyone looking at the thread can see it has been answered. Anyone looking for a similar question ( admittedly probably unlikely here ) can easily identify posts answering it.

    Sincerely,

    Bob


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Thursday, January 25, 2018 11:08 AM