Saturday, February 19, 2011

Parallel Programming .NET Framework 4.0 PART-II

In my last Blog  post http://mstecharchitect.blogspot.com/2011/02/parallel-programming-in-net-40.html I introduced the Task Class. Now we are going to see how we can get Computed values from asynchronously executed Task using Task<T>.

Here is the  Example returning values from Task.

image

Here the above task body delegate returns a value that is exposed via the Result property on the task. When you access the Result property, you will get the result immediately if the task has already completed, or otherwise the call will block until the computation completes.

Next we are going execute two Tasks and wait for them to complete and print their Results .

image

Nandri(Thanks)

Sreenivasaragvan

No comments: