Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to debug async code?

I've been trying to make a simple app that can take a list of youtube URLs and download them as MP3s to a specified folder. However, it's not downloading the files. (I used to be alright at this but I guess the lack of practice over the summer has ruined it)

First of all, the code: https://gist.github.com/ericBG/159debbcdb606647afb8 (I know it's not exactly minimal but its quite small anyways and I'm not too sure where the problem lies)

So, what happens is, it's meant to have some output something like:

Enter folder path where you would like output .mp3 files to be saved:
G:\MusicTemp
Enter any youtube videos you would like downloaded:
https://www.youtube.com/watch?v=N6eUF30HXWY
API requested for http://youtube.com/watch?v=N6eUF30HXWY
Downloading API response for http://youtube.com/watch?v=N6eUF30HXWY
Song requested for http://youtube.com/watch?v=N6eUF30HXWY
Completed download.
Enter any youtube videos you would like downloaded:

(the video is just the shortest video I easily found btw) and the file downloaded as "Video Title".mp3 at the path.

What happens is this however:

Enter folder path where you would like output .mp3 files to be saved:
G:\MusicTemp
Enter any youtube videos you would like downloaded:
https://www.youtube.com/watch?v=N6eUF30HXWY
API requested for http://youtube.com/watch?v=N6eUF30HXWY
Downloading API response for http://youtube.com/watch?v=N6eUF30HXWY
Completed download.
Enter any youtube videos you would like downloaded:

and the file is not at the path.

I have a feeling this is due to some of my async programming. However, I am not sure how to debug this, as I do not know which tools let me step through and see where I've gone wrong, and then correct . Would the VS Community debugger let me debug this code well? Thank you!

like image 951
It'sNotALie. Avatar asked Sep 08 '15 11:09

It'sNotALie.


1 Answers

Copy of comment because that's the answer to the question (not the code problem solution):

You can debug it like normal code. Set a breakpoint use step into or step over and walk through the code. If you've multiple threads it could be a pain because the debugger jumps from one thread to another. If you only want to debug one thread go to the thread window (debug/windows/threads) find the current one (yello arrow) and freeze all other threads.

like image 154
Sebastian Schumann Avatar answered Oct 16 '22 06:10

Sebastian Schumann