Presentation is loading. Please wait.

Presentation is loading. Please wait.

12/2/2018 4:10 AM © 2009 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered.

Similar presentations


Presentation on theme: "12/2/2018 4:10 AM © 2009 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered."— Presentation transcript:

1 12/2/2018 4:10 AM © 2009 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.

2 Async Made Simple in Windows 8, with C# and Visual Basic
12/2/2018 4:10 AM DEV332 Async Made Simple in Windows 8, with C# and Visual Basic Dustin Campbell Senior Program Manager Microsoft Corporation © 2007 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.

3 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

4 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.

5 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.

6 C# and Visual Basic let you do asynchronous programming without callbacks

7 Using await with the Windows Runtime
demo Using await with the Windows Runtime

8 async makes your method asynchronous

9 await makes the rest of your method a callback

10 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

11 Awaitables At Windows 8 Release 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 Already running await directly Can await multiple times Store and await later Or, AsTask and await later

12 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

13 demo Coordinating Tasks

14 Task lets you coordinate activities

15 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);

16 demo Cancellation

17 Cancellation and Progress
Pass CancellationToken to send cancellation Pass IProgress to receive progress updates await FooAsync(…, cancel, progress); await FooAsync(…).AsTask(cancel, progress);

18 Further reading and documentation
Async homepage: What's New for Visual C# in Visual Studio 2012 RC: What's New for Visual Basic in Visual Studio 2012 RC:

19 No more callbacks!

20 DEV Track Resources Visual Studio Home Page :: Somasegar’s Blog :: Jason Zander’s Blog :: Facebook :: Twitter ::

21 Resources Learning TechNet http://europe.msteched.com
Connect. Share. Discuss. Microsoft Certification & Training Resources TechNet Resources for IT Professionals Resources for Developers

22 Submit your evals online
12/2/2018 4:10 AM Evaluations Submit your evals online © 2007 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.

23 12/2/2018 4:10 AM © 2012 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. © 2009 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.


Download ppt "12/2/2018 4:10 AM © 2009 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered."

Similar presentations


Ads by Google