Diese Präsentation wurde erfolgreich gemeldet.
Wir verwenden Ihre LinkedIn Profilangaben und Informationen zu Ihren Aktivitäten, um Anzeigen zu personalisieren und Ihnen relevantere Inhalte anzuzeigen. Sie können Ihre Anzeigeneinstellungen jederzeit ändern.

How to meets Async and Task

1.924 Aufrufe

Veröffentlicht am

2016.11.09 MS MVP Summit Special: A Night of Lightning Talks Kouji Matsui (@kekyo2)

Veröffentlicht in: Software
  • DOWNLOAD THAT BOOKS INTO AVAILABLE FORMAT (2019 Update) ......................................................................................................................... ......................................................................................................................... Download Full PDF EBOOK here { http://bit.ly/2m6jJ5M } ......................................................................................................................... Download Full EPUB Ebook here { http://bit.ly/2m6jJ5M } ......................................................................................................................... Download Full doc Ebook here { http://bit.ly/2m6jJ5M } ......................................................................................................................... Download PDF EBOOK here { http://bit.ly/2m6jJ5M } ......................................................................................................................... Download EPUB Ebook here { http://bit.ly/2m6jJ5M } ......................................................................................................................... Download doc Ebook here { http://bit.ly/2m6jJ5M } ......................................................................................................................... ......................................................................................................................... ................................................................................................................................... eBook is an electronic version of a traditional print book that can be read by using a personal computer or by using an eBook reader. (An eBook reader can be a software application for use on a computer such as Microsoft's free Reader application, or a book-sized computer that is used solely as a reading device such as Nuvomedia's Rocket eBook.) Users can purchase an eBook on diskette or CD, but the most popular method of getting an eBook is to purchase a downloadable file of the eBook (or other reading material) from a Web site (such as Barnes and Noble) to be read from the user's computer or reading device. Generally, an eBook can be downloaded in five minutes or less ......................................................................................................................... .............. Browse by Genre Available eBooks .............................................................................................................................. Art, Biography, Business, Chick Lit, Children's, Christian, Classics, Comics, Contemporary, Cookbooks, Manga, Memoir, Music, Mystery, Non Fiction, Paranormal, Philosophy, Poetry, Psychology, Religion, Romance, Science, Science Fiction, Self Help, Suspense, Spirituality, Sports, Thriller, Travel, Young Adult, Crime, Ebooks, Fantasy, Fiction, Graphic Novels, Historical Fiction, History, Horror, Humor And Comedy, ......................................................................................................................... ......................................................................................................................... .....BEST SELLER FOR EBOOK RECOMMEND............................................................. ......................................................................................................................... Blowout: Corrupted Democracy, Rogue State Russia, and the Richest, Most Destructive Industry on Earth,-- The Ride of a Lifetime: Lessons Learned from 15 Years as CEO of the Walt Disney Company,-- Call Sign Chaos: Learning to Lead,-- StrengthsFinder 2.0,-- Stillness Is the Key,-- She Said: Breaking the Sexual Harassment Story That Helped Ignite a Movement,-- Atomic Habits: An Easy & Proven Way to Build Good Habits & Break Bad Ones,-- Everything Is Figureoutable,-- What It Takes: Lessons in the Pursuit of Excellence,-- Rich Dad Poor Dad: What the Rich Teach Their Kids About Money That the Poor and Middle Class Do Not!,-- The Total Money Makeover: Classic Edition: A Proven Plan for Financial Fitness,-- Shut Up and Listen!: Hard Business Truths that Will Help You Succeed, ......................................................................................................................... .........................................................................................................................
       Antworten 
    Sind Sie sicher, dass Sie …  Ja  Nein
    Ihre Nachricht erscheint hier

How to meets Async and Task

  1. 1. How to meets Async and Task 2016.11.08 MVP SUMMIT SPECIAL: A NIGHT OF LIGHTNING TALKS KOUJI MATSUI (@KEKYO2)
  2. 2. Kouji Matsui - kekyo • NAGOYA city, AICHI pref., JP • Twitter – @kekyo2 / Facebook • ux-spiral corporation • Microsoft Most Valuable Professional VS and DevTech 2015- • Certified Scrum master / Scrum product owner • Center CLR organizer. • .NET/C#/F#/IL/metaprogramming or like… • Bike rider
  3. 3. Agenda Continuation Passing Style .NET Task / async-await / F# Async workflow Continuation Linking
  4. 4. Continuation Passing Style Continuation-passing style (CPS) is a style of programming in which control is passed explicitly in the form of a continuation. “continuation-passing style” - Wikipedia
  5. 5. Continuation Passing Style Continuation function passing to argument Continuation implement with nested lambda expressions… Standard direct style
  6. 6. Continuation Passing Style (Details) Continuation-Passing style Continuation implementation nearly equals “Callback”
  7. 7. Continuation Passing Style (Details) The callback technics likely async continuation handler in JavaScript. Continuation-Passing style Don’t worry!! This technics naming “CPS!!”
  8. 8. Continuation Passing Style Understand CPS?
  9. 9. Agenda Continuation Passing Style .NET Task / async-await / F# Async workflow Continuation Linking
  10. 10. The keyword: .NET Task The “Task” control interface in .NET 4.0. In .NET 4.5 with C# 5.0, Task can handle in “async-await” style. What relationship between Task and CPS?
  11. 11. .NET Task (In .NET 4.0 / C# 4.0) .NET 4.0 Task is using with ContinueWith function. Continuation passing into Task.ContinueWith() --> likely CPS
  12. 12. .NET Task (In .NET 4.5/C# 5.0) And in .NET 4.5/C# 5.0 with “async-await” style: That means “Continuation” OK? Using Task with async-await
  13. 13. .NET Task comparison So, the continuation in async-await: Means CPS for “async-await” syntax sugar. In .NET 4.0 (C# 4.0 Task only) And .NET 4.5 (C# 5.0 async-await)
  14. 14. F# Async workflow Async workflow supported from F# 2.0. Integrated seamless async handling into F# syntax (In .NET 2.0) What relationship between Async and CPS?
  15. 15. F# Async workflow Structure nearly equals “async-await.” That’s CPS? Returned Async<‘T> type ※ let! (Let-Bang) is awaiting for Async<‘T>, and bound ‘T value. Means C#’s await keyword. ※ If continuation implement in F# Async workflow, use Async.FromContinuations<‘T>.
  16. 16. Overall Async implementations .NET Task : using ContinueWith .NET Task : using async-await F# Async workflow : using let! Both all patterns nearly with Continuation-Passing style?
  17. 17. Agenda Continuation Passing Style .NET Task / async-await / F# Async workflow Continuation Linking
  18. 18. Connection both continuations Can I connect by seamless between .NET Tasks and F# Asyncs? ◦ Before thinking, very nearly structure and interfaces for Task<T> and Async<‘T>. Then? ◦ Can use await in C# for F#’s Async<‘T>? ◦ And/or can use let! in F# async workflow for Task<T>? ◦ If can, use let!, use!, do!, return! handling directly with HttpClient.GetStreamAsync().
  19. 19. Senario for .NET Task / C# side: Declare augumented function “AsTask” on Async<‘T> class. Can conversion from Async<‘T> to Task<T>. ◦ Use Async.StartWithContinuations<T> function: Manipulate “TaskCompletionSource<T> class” (Handled SetResult, SetException and SetCanceled functions) and returns Task<T>. Implements Async<‘T>.GetAwaiter function (Augumented). ◦ Can directly awaitable for Async<‘T> in C#.
  20. 20. Senario for .NET Task / C# side: Can directly awaitable for Async<int>. C# compiler invoking GetAwaiter function.
  21. 21. Senario for F# Async workflow side: Declare augumented function “AsAsync” on Task<T> class. Can conversion from Task<T> to Async<‘T>. ◦ Use Async.FromContinuations<T> function: Manipulate Async<‘T> functions from Task.ContinueWith function’s callbacks. And declare augumented function “Source” on AsyncBuilder<‘T> class. ◦ Source function argument is “Task<T>” type and convet to Async<‘T>, then can use directly let!, use!, do! and return! for Task<T> in F# Async workflow.
  22. 22. Senario for F# Async workflow side: Can directly awaiting for Task<int>. F# compiler translate calling “Source” function.
  23. 23. Other tips: Conversion both System.Void and FSharp.Unit in type-safer: ◦ If awaiting for Async<unit> in C#, cannot receive result value (void). ◦ If using Task (Non-generic) in F# async workflow, can only do! expression. Support the “CancellationToken”: ◦ .NET Task is explicitly handling CancellationToken (ex: argument received). F# Async workflow is implicitly handling CancellationToken (Async.DefaultCancellationToken). ◦ --> Add CancellationToken argument for AsTask/AsAsync functions. Don’t use Async.RunSynchronous function: ◦ If use RunSynchronous function, will be hard-blocked current thread nearly invoking Task.Wait. Implements using for Async.FromContinuations<‘T> or Async.StartWithContinuations<‘T>. Implement new type “AsyncCompletionSource<‘T>”: ◦ Async.FromContinuations<T> function handle diffecults (by callback structure) for internal impls. I want to delegation-based interface likely “TaskCompletionSource<T>” class.
  24. 24. Thanks join! The implementations --> GitHub: FusionTasks ◦ https://github.com/kekyo/FSharp.Control.FusionTasks ◦ https://www.nuget.org/packages/FSharp.Control.FusionTasks.FS40/ Progressing: ◦ FusionTasks (for .NET Core waiting for F# RTM :) Adjusting PCL profiles :( ◦ fscx (F# expandable compiler project) https://github.com/fscx-projects/ ◦ RelaxVersioner (Git based very easy versioner) https://github.com/kekyo/RelaxVersioner/ My blog (Sorry default language in Japanese) ◦ http://www.kekyo.net/

×