1 / 0

Easy Async for Windows Store Apps in Microsoft Visual C# and Microsoft Visual Basic

Easy Async for Windows Store Apps in Microsoft Visual C# and Microsoft Visual Basic. Lucian Wischik Senior Program Manager Managed Languages. DEV-B317. Easy Async for Windows Store Apps in Microsoft Visual C# and Microsoft Visual Basic. p lease wait for the next slide.

meg
Download Presentation

Easy Async for Windows Store Apps in Microsoft Visual C# and Microsoft Visual Basic

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Easy Async for Windows Store Apps in Microsoft Visual C# and Microsoft Visual Basic Lucian Wischik Senior Program Manager Managed Languages DEV-B317
  2. Easy Async for Windows Store Apps in Microsoft Visual C# and Microsoft Visual Basic please wait for the next slide clicking won’t make it come any faster Lucian Wischik Senior Program Manager Managed Languages DEV-B317
  3. The Future is the Future Responsiveness and scalability Async is becoming the norm Futures: Modern abstractions Details: Different but similar .NET Async Windows Runtime Async
  4. Synchronous vs. Asynchronous var data = DownloadData(...); ProcessData(data); STOP DownloadData ProcessData var future = DownloadDataAsync(...); future.ContinueWith(data => ProcessData(data)); DownloadDataAsync ProcessData
  5. Synchronous vs. Asynchronous var data = DownloadData(...); ProcessData(data); STOP STOP DownloadData ProcessData var future = DownloadDataAsync(...); future.ContinueWith(data => ProcessData(data)); DownloadDataAsync ProcessData
  6. C# and Visual Basic let you doasynchronous programmingwithout callbacks
  7. Demo Using await with the Windows Runtime
  8. await makes the rest of your method a callback
  9. async“makes your method asynchronous”lets you put awaits in it
  10. Awaitables Task Task<TResult> Returned from asyncC# and Visual Basic APIs Already running await directly Can await multiple times Store and awaitlater IAsyncAction IAsyncOperation<TResult> Returned from asyncWindows Runtime APIs Already running awaitdirectly Can await multiple times Store and await later Or, AsTask and awaitlater
  11. 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
  12. Demo Coordinating Tasks
  13. Tasklets you coordinate activities
  14. Task helpers Yielding control await Task.Delay(5000); await Task.Yield(); Background running var result = await Task.Run(() => { … work … }); Parallel composition varwinningTask= await Task.WhenAny(task1, task2); var results = await Task.WhenAll(task1, task2);
  15. Demo Cancellation
  16. Cancellation and Progress Pass CancellationToken to send cancellation Pass IProgress to receive progress updates await FooAsync(…, cancel, progress); await FooAsync(…).AsTask(cancel, progress);
  17. Windows 8 has taken a big bet on asynchronous APIs
  18. The await keyword makes consuming async APIs simple
  19. No more callbacks!
More Related