Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
Author. Blogger. Speaker. C# MVP. Geek.
12:38
12:38
Load app
content
Sort
data
Process
records
Asynchronous task
UsingTasks
UsingAsyncandAwait
private async Task RunAsync()
{
var x = 10;
await Task.Delay(2000);
Debug.WriteLine(x);
}
private Task RunAsync()
{
<RunAsync>d__1 stateMachine = new <RunAsync>d__1 {
<>t__builder = AsyncTaskMethodBuilder.Create(...
if (num != 0)
{
this.<x>5__1 = 10;
awaiter = Task.Delay(2000).GetAwaiter();
if (!awaiter.IsCompleted)
{
. . . . . . . . . ...
private async void RunAsync()
{
var x = 10;
await Task.Delay(2000);
Debug.WriteLine(x);
}
private void RunAsync()
{
<RunAsync>d__1 stateMachine = new <RunAsync>d__1 {
<>t__builder = AsyncVoidMethodBuilder.Create(...
CloserlookatAsyncandAwait
AsyncandAwaitinASP.NET
$.post("ajax/test.html", function (data) {
$(".result").html(data);
})
Task.Run(() => { /* Lots of work to do! */ });
Task<string>.Run(() =>
{
/* Lots of work to do! */
return "Hello World!";
}...
Task.Run(() => { /* Lots of work to do! */ })
.ContinueWith((t) => { Debug.WriteLine("Done!"); });
await Task.Run(() => { ...
Task.Run(() => "Hello World!")
.ContinueWith((task) => Debug.WriteLine(task.Result));
var result = await Task.Run(() => "H...
private Task RunAsync()
{
<RunAsync>d__1 stateMachine = new <RunAsync>d__1 {
<>t__builder = AsyncTaskMethodBuilder.Create(...
Task.Run(() => { /* Lots of work to do! */ })
.ContinueWith((t) => { Debug.WriteLine("Done!"); });
await Task.Run(() => { ...
if (num != 0)
{
this.<x>5__1 = 10;
awaiter = Task.Delay(2000).GetAwaiter();
if (!awaiter.IsCompleted)
{
. . . . . . . . . ...
Task.Delay(1).ContinueWith((t) =>
{
Dispatcher.Invoke(() =>
{
});
}).Wait();
RunAsync().Wait();
Author. Blogger. Speaker. C# MVP. Geek.
Asynchronous programming
Asynchronous programming
Asynchronous programming
Asynchronous programming
Asynchronous programming
Asynchronous programming
Asynchronous programming
Asynchronous programming
Asynchronous programming
Asynchronous programming
Asynchronous programming
Asynchronous programming
Asynchronous programming
Asynchronous programming
Asynchronous programming
Asynchronous programming
Asynchronous programming
Asynchronous programming
Asynchronous programming
Asynchronous programming
Asynchronous programming
Asynchronous programming
Asynchronous programming
Asynchronous programming
Asynchronous programming
Asynchronous programming
Asynchronous programming
Asynchronous programming
Asynchronous programming
Asynchronous programming
Asynchronous programming
Asynchronous programming
Asynchronous programming
Asynchronous programming
Asynchronous programming
Asynchronous programming
Asynchronous programming
Asynchronous programming
Upcoming SlideShare
Loading in …5
×

Asynchronous programming

Slides from my LIDNUG presentation on Asynchronous Programming.

Related Books

Free with a 30 day trial from Scribd

See all

Related Audiobooks

Free with a 30 day trial from Scribd

See all

Asynchronous programming

  1. 1. Author. Blogger. Speaker. C# MVP. Geek.
  2. 2. 12:38
  3. 3. 12:38 Load app content Sort data Process records Asynchronous task
  4. 4. UsingTasks
  5. 5. UsingAsyncandAwait
  6. 6. private async Task RunAsync() { var x = 10; await Task.Delay(2000); Debug.WriteLine(x); }
  7. 7. private Task RunAsync() { <RunAsync>d__1 stateMachine = new <RunAsync>d__1 { <>t__builder = AsyncTaskMethodBuilder.Create(), <>1__state = -1 }; stateMachine.<>t__builder.Start<<RunAsync>d__1>(ref stateMachine); return stateMachine.<>t__builder.Task; }
  8. 8. if (num != 0) { this.<x>5__1 = 10; awaiter = Task.Delay(2000).GetAwaiter(); if (!awaiter.IsCompleted) { . . . . . . . . . . . . return; } } else { . . . . . } awaiter.GetResult(); awaiter = new TaskAwaiter(); Debug.WriteLine(this.<x>5__1);
  9. 9. private async void RunAsync() { var x = 10; await Task.Delay(2000); Debug.WriteLine(x); }
  10. 10. private void RunAsync() { <RunAsync>d__1 stateMachine = new <RunAsync>d__1 { <>t__builder = AsyncVoidMethodBuilder.Create(), <>1__state = -1 }; stateMachine.<>t__builder.Start<<RunAsync>d__1>(ref stateMachine); }
  11. 11. CloserlookatAsyncandAwait
  12. 12. AsyncandAwaitinASP.NET
  13. 13. $.post("ajax/test.html", function (data) { $(".result").html(data); })
  14. 14. Task.Run(() => { /* Lots of work to do! */ }); Task<string>.Run(() => { /* Lots of work to do! */ return "Hello World!"; });
  15. 15. Task.Run(() => { /* Lots of work to do! */ }) .ContinueWith((t) => { Debug.WriteLine("Done!"); }); await Task.Run(() => { /* Lots of work to do! */ }); Debug.WriteLine("Done!");
  16. 16. Task.Run(() => "Hello World!") .ContinueWith((task) => Debug.WriteLine(task.Result)); var result = await Task.Run(() => "Hello World!"); Debug.WriteLine(result);
  17. 17. private Task RunAsync() { <RunAsync>d__1 stateMachine = new <RunAsync>d__1 { <>t__builder = AsyncTaskMethodBuilder.Create(), <>1__state = -1 }; stateMachine.<>t__builder.Start<<RunAsync>d__1>(ref stateMachine); return stateMachine.<>t__builder.Task; }
  18. 18. Task.Run(() => { /* Lots of work to do! */ }) .ContinueWith((t) => { Debug.WriteLine("Done!"); }); await Task.Run(() => { /* Lots of work to do! */ }); Debug.WriteLine("Done!");
  19. 19. if (num != 0) { this.<x>5__1 = 10; awaiter = Task.Delay(2000).GetAwaiter(); if (!awaiter.IsCompleted) { . . . . . . . . . . . . return; } } else { . . . . . } awaiter.GetResult(); awaiter = new TaskAwaiter(); Debug.WriteLine(this.<x>5__1);
  20. 20. Task.Delay(1).ContinueWith((t) => { Dispatcher.Invoke(() => { }); }).Wait(); RunAsync().Wait();
  21. 21. Author. Blogger. Speaker. C# MVP. Geek.

    Be the first to comment

    Login to see the comments

  • anil_awadh

    Apr. 7, 2015
  • joobn

    Apr. 14, 2015
  • TadeuszSobol

    May. 1, 2015
  • jimmiethesun

    May. 28, 2015
  • AliBayat5

    Jan. 12, 2017
  • Jasonmao5

    Apr. 10, 2018
  • professional_fci

    Aug. 12, 2018

Slides from my LIDNUG presentation on Asynchronous Programming.

Views

Total views

41,676

On Slideshare

0

From embeds

0

Number of embeds

36,917

Actions

Downloads

100

Shares

0

Comments

0

Likes

7

×