2

I have an application that use async CTP library to be able to use async/await keywords, and I know that the actual version of C#, 5.0, has this feature by default, and it is not all the exact version that async CTP. I mean that for example in async CTP exist TaskEx and in C# 5.0 not exists, is Task.

But dispite of these diferences, I would like to know if the Task object that is returned by the async methods are the same or not.

In my case, I have an Interface for a repository to access to the data base. This repository by the moment is implemented by a class that use C# 4.0, but it can use asyc CTP to return a Task and use the await keyowrd. But in the future, I would like to use other classes that use C# 5.0.

If my interace define a method that returns a Task, can I implement this inteface with the class that use C# 4.0 and the class that use C# 5.0? Or exists diference in the Task object in async CTP and C# 5.0?

PD: I correct the version of C#, I mean 5,0 instead of C# 4.5.

PD2: it seems that with VS2012 I can use Microsoft.Bcl.Async and Microsoft.CompilerServices.AsyncTargetingPack to use the asyn/await keywords in project which target is .NET 4.0. But I don't know which is the difference between them.

Álvaro García
  • 15,452
  • 25
  • 82
  • 152

1 Answers1

2

It's the same Task type that is returned. This type was introduced in .NET 4.0 as part of the Task Parallel Library.

However, I would upgrade everything to VS2012 if I were you, replacing the Async CTP with Microsoft.Bcl.Async. The underlying compiler types are different (and mutually incompatible), and there are known bugs in the Async CTP as well as installation issues.

Stephen Cleary
  • 376,315
  • 69
  • 600
  • 728
  • what is the difference between Microsoft.Bcl.Async and Microsoft.CompilerServices.AsyncTargetingPack? I see that ATP is release before Bcl, but Bcl is beta and ATP is a final version. – Álvaro García Dec 10 '12 at 09:25
  • I believe ATP was the first attempt at updating the Async CTP for VS2012. Bcl.Async is a more comprehensive approach (supports more platforms); I expect Bcl.Async to deprecate ATP. However, AFAIK, Microsoft has not stated this. – Stephen Cleary Dec 10 '12 at 13:05