Last post Nov 06, 2020 06:45 PM by mgebhard
Nov 06, 2020 05:33 PM|wavemaster|LINK
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.
Nov 06, 2020 05:42 PM|mgebhard|LINK
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?
Nov 06, 2020 05:53 PM|wavemaster|LINK
Nov 06, 2020 06:45 PM|mgebhard|LINK
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.