From the course: Advanced C#: Thread-Safe Data with Concurrent Collections

Unlock this course with a free trial

Join today to access over 22,600 courses taught by industry experts.

Debug the Queue multiple-thread problem

Debug the Queue multiple-thread problem

- [Instructor] Let's take a minute to debug the application and see if we can determine why we're getting that blank row or more than one blank row when we were dequeing the items from the queue. To do that I'll go to the demo two method and I'll put a break point on the while loop by pressing F9 and then press F5 to run the application with the debugger attached. I've added two watch variables to my watch one window. So I've got the underscore robots and I've got the individual robot that'll be populated here inside the while loop. And you can see there are ten items in the queue. So what's up with that blank row? Let's drill down into the queue. Here's the first item, robot 10. Let's look at the second item. This is where the problem lies. My code was supposed to set the name of this to robot 20, it's a null string. The team name didn't get set. The team color is at the default and the default value for the ID.…

Contents