3

I'm stuck debugging a tasked based application. It hangs. :-)

Looking at my list of tasks at the time of the hang I see the following:

Tasks window from VS 2017

Everything is hung, and if I hover over status, this is (as expected) a direct chain to everyone waiting for #8 to complete. 8 is in the "Scheduled" state, which according to the documentation, is "A scheduled task is one that has not yet been run and, therefore, does not yet have a call stack, assigned thread, or related information." (see VS Documentation).

Everything is hung at this point. Looking at the thread window there are two threads. One is the main thread, and is stopped at a await for task 11 to finish. There is also a second thread, a worker thread, but its location is "not available". The debugger output window has nothing interesting in it (e.g. an exception thrown, etc.).

The specific question I have is: is the definition of scheduled really correct (and I have messed up the runtime somehow so it isn't scheduling this task to run) or is the definition of scheduled more subtle than what is in the documentation? Basically, when it comes down to it, I'm trying to figure out where to focus my debugging efforts!

Gordon
  • 3,012
  • 2
  • 26
  • 35
  • 1
    [async is not about threads](https://stackoverflow.com/q/17661428/11683), and you most likely [have deadlocked](https://stackoverflow.com/q/15021304/11683) by not using `async` properly. – GSerg Feb 01 '18 at 16:38
  • I agree that is most likely - except that I would expect that the "status" would all be "Awaiting" in that case, wouldn't it? – Gordon Feb 01 '18 at 16:40

1 Answers1

1

As @GSerg said, there was a real deadlock. So, tracking down that deadlock with a lot of print statements is what allowed me to figure out what was going on.

I do not know why the task state was listed as scheduled - I would have thought it should be in some other state.

Gordon
  • 3,012
  • 2
  • 26
  • 35