Are coroutines obsoleted by Async Targeting Pack?

Topics: Actions & Coroutines
May 22, 2012 at 9:26 PM

Microsoft recently released the Async Targeting Pack which allows using the C# 5 async/await keywords with apps targeting Silverlight 5 / .NET 4. I'm not too familiar with the C# 5 async features or coroutines, but from a quick glance at the two, it appears that they are intended to solve the same problem (the pain of doing async programming) and the async/await solution is a bit cleaner.

Can anyone more familiar with these technologies comment on this? Are coroutines more-or-less obsolete if you're targeting SL5 and therefore able to use the Async Targeting Pack?

May 22, 2012 at 9:39 PM
Edited May 22, 2012 at 9:39 PM

Coroutines will not be obsolete becuase the async/await syntax is also an implementation of coroutines (see the wikipedia article on coroutines). However the implementation of coroutines that CM uses with IEnumerable<IResult> will be obsolete since async/await does the same work. From my testing the targeting pack only works in VS11Beta, you cannot use it with Async CTP on VS2010 which is really disappointing because that could have enabled using a mix of VS2010 and VS11Beta in my current project.

May 22, 2012 at 11:09 PM

Thanks for the info. And sorry, I thought this would be obvious, but I did mean "are Caliburn.Micro coroutines obsoleted by the Async Targeting Pack". Perhaps the CM coroutine docs could be updated to point people to the Async Targeting Pack page and suggest that they use it if possible (e.g. if targeting SL 5 and able to use VS 11). After reading a bit more on async/await today, it does seem significantly cleaner than using the CM coroutine implementation.

P.S. Agreed that it's disappointing about the Async Targeting Pack needing VS11... oh well, time to upgrade everyone in the office I guess.

Coordinator
May 23, 2012 at 2:23 AM

CM's IResult has more uses than just async programming. So, it won't go away entirely.

Dec 13, 2012 at 1:29 PM

What other uses than asnyc progamming does IResult have?

Dec 18, 2012 at 6:36 PM
bitbonk wrote:

What other uses than asnyc progamming does IResult have?

"See how I took advantage of context.View? This opens up a lot of possibilities while maintaining separation between the view and the view model. Just to list a few interesting things you could do with IResult implementations: show a message box, show a VM-based modal dialog, show a VM-based Popup at the user’s mouse position, play an animation, show File Save/Load dialogs, place focus on a particular UI element based on VM properties rather than controls, etc. Of coarse, one of the biggest opportunities is calling web services."