The context is very important here. When you run such a task, it uses the current scheduler - and if it assumes that it will be able to use the current thread, you will be effectively blocked when you wait for it.
The same code in a different context will be fine.
The reason others say that it works for them, but it does not work for you, is because, no doubt, you are using this code in a different context for other people, but you have not shown us a short but complete program , just this fragment, so everyone is trying to reproduce it differently. (I see that you have now uploaded a project that will no doubt shed more light. Of course, a short, but complete program that can be posted in the question is usually preferred.)
Jon skeet
source share