AwaitableUI is a .NET library that adds async/await keyword support to controls to enable asynchronous UI using structured code instead of events.
Supports WinRT (for Windows 8 Consumer Preview), Silverlight 4.0, Silverlight for Windows Phone 7.1 (Mango) and WPF.
Note: The current version of the library for Windows 8 RTM is maintained as part of the
WinRT XAML Toolkit project and includes some improvements
Reach the new height in simplicity of asynchronous UI development in WinRT, Silverlight and WPF.
Current state of the project
Current version only supports WinRT based on Windows 8 Consumer Preview as well as WPF, Silverlight and Windows Phone 7.1 (Mango) based on Async CTP3.
How do I use it
- EventAsync helper class that simplifies converting single-shot events into awaitable tasks
- Button.WaitForClickAsync() extension method- to wait for a click of a button or one of a collection of buttons
- Storyboard.BeginAsync() extension method - to begin a storyboard and wait for its completion
- FrameworkElement.WaitForLoadedAsync()/WaitForUnloadedAsync()/WaitForLayoutUpdateAsync() extension methods - to enable waiting for the associated events
- Selector.WaitForSelectionChangedAsync() extension method - to wait for a selection change in a ListBox, ListView and other Selectors
- Sample code for some of the above and an two implementations of a custom dialog class comparing the same functionality implemented with these extension methods + async/await keywords and using the classic event-driven pattern.
You need to
- Download the source code.
- For WinRT code - you will need Windows 8 Consumer Preview with VS 11
- For anything else - VS 2010 Async CTP3 Silverlight and Windows Phone SDKs if you want to build these projects.
Then just run the samples and browse the code and let me know what you think. Do you find it easy to use? Would you like to see more extension methods or samples?
The project started together with an article on
- read it to learn more about it.
- The set of extension methods is rather limited to just prove the concept.
- Need a sample/library update to enable waiting for first/all of a selection of multiple types of tasks and cancel all others when done waiting.