Here is what I can see: you are using
Thread.Sleep
. I don't have v.4.5 to test it, but let's see: it's explicitly documented, that the invocation of
async
methods does not create a new thread; using them does not require multithreading:
http://msdn.microsoft.com/en-us/library/vstudio/hh191443.aspx#BKMK_Threads[
^].
It looks like you don't create any threads either. Now, let's combine these facts with the principle "there is no such thing as miracle". What is the thread where you call
Thread.Sleep
then? This is you UI thread. No wonder it becomes unresponsive for a while. If you repeat it on regular basis, it will be permanently unresponsive.
Did you follow my logic? So, it looks like if you want to use the pattern based on Sleep (which is itself perfectly fine), you can practically do it only using "real" threading paradigm.
Generally, I find Microsoft claim "The async-based approach to asynchronous programming is preferable to existing approaches in almost every case" (on the page I referenced above) highly exaggerated. This is not innovative in its basic aspects, just the opposite, it looks like getting back to old times when cooperative multithreading was more extensively used. It has its value, of course, for number of models, but it should be used with care, the care is some different ways than with threads.
—SA