C# Async programming pitfall
I really like the TPL, and I really like the async/await syntax. It is drastically better than any other attempt I’ve seen to handle concurrency.
But it also has a really major issue. There is no way to properly debug things. Imagine that I have the following code:
public Task DoSomething()
return new TaskCompletionSource<object>().Task;
And now imagine that I have some code that is going to do an await DoSomething();
What is going to happen? This is a never ending task, so we’ll never return. And that is fine, except that there is absolutely no way to see that. I have no way of seeing which task didn’t return, and I have no way of seeing all the pending tasks, and what they are all waiting for, etc. I’ve run into something like that (obviously a lot harder to figure out) too many times.
If I was using non async code, it would be obvious that there is this thread that is stopped on this thing, and I could figure it out. For us, this make it a lot harder to work with.