TechEd 2013 12/9/2018 4:17 AM © 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.
12/9/2018 4:17 AM DEV-B317 Easy Async for Windows Store Apps in Microsoft Visual C# and Microsoft Visual Basic Alex Turner Senior Program Manager Managed Languages © 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.
The Future is the Future Responsiveness and scalability Async is becoming the norm Futures: Modern abstractions Details: Different but similar Far more similar since Beta .NET Async Windows Runtime Async
Synchronous vs. Asynchronous var data = DownloadData(...); ProcessData(data); STOP ProcessData DownloadData var future = DownloadDataAsync(...); future.ContinueWith(data => ProcessData(data)); DownloadDataAsync ProcessData © 2010 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.
Synchronous vs. Asynchronous var data = DownloadData(...); ProcessData(data); STOP ProcessData DownloadData STOP var future = DownloadDataAsync(...); future.ContinueWith(data => ProcessData(data)); DownloadDataAsync ProcessData © 2010 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.
C# and Visual Basic let you do asynchronous programming without callbacks
Demo Using await with the Windows Runtime
async makes your method asynchronous
await makes the rest of your method a callback
Awaitables At Windows 8 Developer Preview Task Task<TResult> Returned from async C# and Visual Basic APIs Already running await directly Can await multiple times Store and await later IAsyncAction IAsyncOperation<TResult> Returned from async Windows Runtime APIs Must be started await directly Can await only once StartAsTask and await later
Awaitables At Windows 8 Release Preview/RTM Task Task<TResult> Returned from async C# and Visual Basic APIs Already running await directly Can await multiple times Store and await later IAsyncAction IAsyncOperation<TResult> Returned from async Windows Runtime APIs Already running await directly Can await multiple times Store and await later Or, AsTask and await later
Task-returning vs. void-returning async Task FooAsync(…); Can be awaited “Give back control” Delegate asynchronous work Use for helper methods Use for library methods async void Foo_Click(…); Cannot be awaited “Fire and forget” Start separate independent flow Use for event handlers Use to override void methods
Demo Coordinating Tasks
Task lets you coordinate activities
Task helpers Yielding control Background running Parallel composition await Task.Delay(5000); await Task.Yield(); Background running var result = await Task.Run(() => { … work … }); Parallel composition Task first = await Task.WhenAny(task1, task2); var results = await Task.WhenAll(task1, task2);
Demo Cancellation
Cancellation and Progress Pass CancellationToken to send cancellation Pass IProgress to receive progress updates await FooAsync(…, cancel, progress); await FooAsync(…).AsTask(cancel, progress);
Windows 8 has taken a big bet on asynchronous APIs
The await keyword makes consuming async APIs simple
No more callbacks!
Plan details and subscriber benefits 12/9/2018 4:17 AM Plan details and subscriber benefits Free Plan for up to 5 users Included for certain paid MSDN subscribers: Version control (TFVC or Git) Comment on changesets & commits Work item tracking and tagging Team rooms Agile planning tools Feedback Management Agile Portfolio Management* Build* Web-based test case management* Load testing* New! Additional information at http://tfs.visualstudio.com * Capability in preview – limits may apply. Authoring load tests requires Visual Studio Ultimate 2013 Preview. © 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.
Learn more and activate today at http://aka.ms/AzureContest MSDN Subscribers – Accelerate Your Development & Test using Cloud VMs We’ve enhanced the Windows Azure MSDN benefit and added cloud use rights for select MSDN software. You’ve already got it, now use it! Activate and try out your Windows Azure MSDN benefit today & you could win an Aston Martin V8 Vantage! Learn more and activate today at http://aka.ms/AzureContest
12/9/2018 4:17 AM More Async talks Mon 1:15pm: Easy Async for Windows Store Apps in Microsoft Visual C# and Microsoft Visual Basic DEV-B317 – You are here Tue 10:15am: Three Essential Tips for Using Async in Microsoft Visual C# and Visual Basic DEV-B319 Wed 8:30am: Creating Async Libraries That Are Modular, Reusable and Fast, in Microsoft Visual C# and Visual Basic DEV-B318 © 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.
Resources Learning TechNet msdn http://channel9.msdn.com/Events/TechEd 12/9/2018 4:17 AM Resources Learning Sessions on Demand http://channel9.msdn.com/Events/TechEd Microsoft Certification & Training Resources www.microsoft.com/learning TechNet msdn Resources for IT Professionals http://microsoft.com/technet Resources for Developers http://microsoft.com/msdn © 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.
Complete an evaluation on CommNet and enter to win! 12/9/2018 4:17 AM Complete an evaluation on CommNet and enter to win! © 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.
12/9/2018 4:17 AM Required Slide *delete this box when your slide is finalized Your MS Tag will be inserted here during the final scrub. Evaluate this session Scan this QR code to evaluate this session and be automatically entered in a drawing to win a prize © 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.
12/9/2018 4:17 AM © 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION. © 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.