locked
Debugging challenge - loop with async tasks RRS feed

  • Question

  • User379720387 posted

    I am wondering how I can improve my debugging situation in a loop with async Tasks.

    Inside this loop there is a Task to check the db for configuration settings that need to be sent to field devices.

    If it finds any a new packet is created and sent out.

    There is a mystery in the sending out part, so I am trying to debug this in VS2019 16.7.2

    The loop keeps generating new tasks and as a result I see the debugger point all over the place and it is impossible to keep track where I am.

    Looking for suggestions on how to do this properly.

    Friday, November 6, 2020 5:33 PM

All replies

  • User475983607 posted

    Log the start, end, and whatever in between rather than trying to single step.  Depending on your need this can be to the console or a DB table. I assume this is not a web application?

    Friday, November 6, 2020 5:42 PM
  • User379720387 posted

    Console app.

    Logging? :(

    Friday, November 6, 2020 5:53 PM
  • User475983607 posted

    Console app.

    Logging? :(

    Yes, logging.  Single stepping is a synchronous operation which can make debugging asynchronous tasks confusing.  Plus stopping execution with a break point can hide logical errors within the code.  Logging on the other hand serializes what happened while the process runs.

    If you are trying to debug code then start one task rather than many.

    Friday, November 6, 2020 6:45 PM