HttpClient.SendAsync using the thread-pool instead of async IO?

this.startRequest is a delegate that points to StartRequest which in turn uses HttpWebRequest.BeginGetResponse to start async IO. HttpClient is using async IO under the covers, just wrapped in a thread-pool Task. That said, note the following comment in SendAsync // BeginGetResponse/BeginGetRequestStream have a lot of setup work to do before becoming async // (proxy, dns, … Read more

Task chaining (wait for the previous task to completed)

This is not Task Chaining. You need to do Task chaining using ContinueWith. Last task would need to update the UI. Task.Factory.StartNew( () => DoThis()) .ContinueWith((t1) => DoThat()) .ContinueWith((t2) => UpdateUi(), TaskScheduler.FromCurrentSynchronizationContext()); Note the last line has TaskScheduler.FromCurrentSynchronizationContext() this will ensure task will run in the synchronization context (UI Thread).

TPL TaskFactory.FromAsync vs Tasks with blocking methods

You absolutely want to use FromAsync when an API offers a BeginXXX/EndXXX version of a method. The difference is that, in the case of something like Stream or Socket or WebRequest, you’ll actually end up using async I/O underneath the covers (e.g. I/O Completion Ports on Windows) which is far more efficient than blocking multiple … Read more

Is there a Threadsafe Observable collection in .NET 4?

There are two possible approaches. The first would be to inherit from a concurrent collection and add INotifyCollectionChanged functionality, and the second would be to inherit from a collection that implements INotifyCollectionChanged and add concurrency support. I think it is far easier and safer to add INotifyCollectionChanged support to a concurrent collection. My suggestion is … Read more

TPL Dataflow, guarantee completion only when ALL source data blocks completed

The issue is exactly what casperOne said in his answer. Once the first transform block completes, the processor block goes into “finishing mode”: it will process remaining items in its input queue, but it won’t accept any new items. There is a simpler fix than splitting your processor block in two though: don’t set PropagateCompletion, … Read more