UPDATE: Version 1 has been officially released. There are separate NuGet packages for .NET and Silverlight. See updated link below.
For those of you eager to try the new async language features in C# 5 and Visual Basic 11, I’ve created just the thing for you. Announcing the “Cocktail Async Pack for Visual Studio 2012”.
The "Cocktail Async Pack for Visual Studio 2012" enables Cocktail/DevForce projects targeting .NET Framework 4.0 or Silverlight 5 to use the Async language feature in C# 5 and Visual Basic 11. This pack requires Visual Studio 2012 and will not work with Visual Studio 2010.
The Pack is available via NuGet and the source code is hosted on github. The NuGet package assumes that you are already using Cocktail, so it doesn’t bring the Cocktail package down with it, but it brings down the “Microsoft Async Targeting Pack for Visual Studio 2012”, which is required in order to use the new language features in .NET 4.0 and Silverlight 5.
NuGet: http://www.nuget.org/packages/Cocktail.AsyncPack
NuGet: http://nuget.org/packages?q=Cocktail
Github: http://github.com/IdeaBlade/Cocktail.AsyncPack
With the “Cocktail Async Pack” added to a project, all Cocktail and DevForce asynchronous operations become awaitable as in the following example. Check it out, play around with it and let me know what you think.
[Export]
public class MainPageViewModel : Screen
{
private IDialogManager _dialogManager;
private NorthwindIBEntities _manager;
[ImportingConstructor]
public MainPageViewModel(IDialogManager dialogManager)
{
_dialogManager = dialogManager;
_manager = new NorthwindIBEntities();
}
public async void SampleAction()
{
var customers = await _manager.Customers.Where(c => c.Country == "UK").ExecuteAsync();
await _dialogManager.ShowMessageAsync(string.Format("Found {0} customers.", customers.Count()), DialogButtons.Ok);
var employees = await _manager.Employees.ExecuteAsync();
await _dialogManager.ShowMessageAsync(string.Format("Found {0} employees.", employees.Count()), DialogButtons.Ok);
}
}
Edited by mgood - 16-Aug-2012 at 4:26pm