Asynchronous programming

Filip Ekberg
Filip EkbergSenior Software Engineer at Invoice2go
Asynchronous programming
Author. Blogger. Speaker. C# MVP. Geek.
Asynchronous programming
Asynchronous programming
Asynchronous programming
Asynchronous programming
Asynchronous programming
12:38
Asynchronous programming
Asynchronous programming
12:38
Load app
content
Sort
data
Process
records
Asynchronous task
Asynchronous programming
Asynchronous programming
Asynchronous programming
Asynchronous programming
Asynchronous programming
UsingTasks
Asynchronous programming
Asynchronous programming
Asynchronous programming
Asynchronous programming
Asynchronous programming
UsingAsyncandAwait
Asynchronous programming
Asynchronous programming
Asynchronous programming
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(),
<>1__state = -1
};
stateMachine.<>t__builder.Start<<RunAsync>d__1>(ref stateMachine);
return stateMachine.<>t__builder.Task;
}
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);
Asynchronous programming
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(),
<>1__state = -1
};
stateMachine.<>t__builder.Start<<RunAsync>d__1>(ref stateMachine);
}
Asynchronous programming
Asynchronous programming
CloserlookatAsyncandAwait
Asynchronous programming
Asynchronous programming
AsyncandAwaitinASP.NET
Asynchronous programming
Asynchronous programming
Asynchronous programming
Asynchronous programming
$.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!";
});
Asynchronous programming
Task.Run(() => { /* Lots of work to do! */ })
.ContinueWith((t) => { Debug.WriteLine("Done!"); });
await Task.Run(() => { /* Lots of work to do! */ });
Debug.WriteLine("Done!");
Task.Run(() => "Hello World!")
.ContinueWith((task) => Debug.WriteLine(task.Result));
var result = await Task.Run(() => "Hello World!");
Debug.WriteLine(result);
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;
}
Task.Run(() => { /* Lots of work to do! */ })
.ContinueWith((t) => { Debug.WriteLine("Done!"); });
await Task.Run(() => { /* Lots of work to do! */ });
Debug.WriteLine("Done!");
Asynchronous programming
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);
Asynchronous programming
Asynchronous programming
Asynchronous programming
Asynchronous programming
Task.Delay(1).ContinueWith((t) =>
{
Dispatcher.Invoke(() =>
{
});
}).Wait();
RunAsync().Wait();
Asynchronous programming
Asynchronous programming
Author. Blogger. Speaker. C# MVP. Geek.
1 of 59

Recommended

Async Programming in C# 5 by
Async Programming in C# 5Async Programming in C# 5
Async Programming in C# 5Pratik Khasnabis
3.4K views22 slides
Asynchronous programming in C# by
Asynchronous programming in C#Asynchronous programming in C#
Asynchronous programming in C#Bohdan Pashkovskyi
425 views17 slides
C# Async Await by
C# Async AwaitC# Async Await
C# Async AwaitSimplilearn
251 views19 slides
Asynchronous Programming in C# - Part 1 by
Asynchronous Programming in C# - Part 1Asynchronous Programming in C# - Part 1
Asynchronous Programming in C# - Part 1Mindfire Solutions
2.1K views19 slides
Intro to Asynchronous Javascript by
Intro to Asynchronous JavascriptIntro to Asynchronous Javascript
Intro to Asynchronous JavascriptGarrett Welson
601 views62 slides
Exception handling in asp.net by
Exception handling in asp.netException handling in asp.net
Exception handling in asp.netNeelesh Shukla
8K views17 slides

More Related Content

What's hot

Multiple Choice Questions on JAVA (object oriented programming) bank 2 -- bas... by
Multiple Choice Questions on JAVA (object oriented programming) bank 2 -- bas...Multiple Choice Questions on JAVA (object oriented programming) bank 2 -- bas...
Multiple Choice Questions on JAVA (object oriented programming) bank 2 -- bas...Kuntal Bhowmick
628 views45 slides
C# Exceptions Handling by
C# Exceptions Handling C# Exceptions Handling
C# Exceptions Handling sharqiyem
3K views38 slides
Developing an ASP.NET Web Application by
Developing an ASP.NET Web ApplicationDeveloping an ASP.NET Web Application
Developing an ASP.NET Web ApplicationRishi Kothari
28.4K views43 slides
Solid principles by
Solid principlesSolid principles
Solid principlesMonica Rodrigues
13.5K views31 slides
Debugging Effectively by
Debugging EffectivelyDebugging Effectively
Debugging EffectivelyColin O'Dell
1.7K views61 slides
Introducing Async/Await by
Introducing Async/AwaitIntroducing Async/Await
Introducing Async/AwaitValeri Karpov
1.2K views26 slides

What's hot(20)

Multiple Choice Questions on JAVA (object oriented programming) bank 2 -- bas... by Kuntal Bhowmick
Multiple Choice Questions on JAVA (object oriented programming) bank 2 -- bas...Multiple Choice Questions on JAVA (object oriented programming) bank 2 -- bas...
Multiple Choice Questions on JAVA (object oriented programming) bank 2 -- bas...
Kuntal Bhowmick628 views
C# Exceptions Handling by sharqiyem
C# Exceptions Handling C# Exceptions Handling
C# Exceptions Handling
sharqiyem3K views
Developing an ASP.NET Web Application by Rishi Kothari
Developing an ASP.NET Web ApplicationDeveloping an ASP.NET Web Application
Developing an ASP.NET Web Application
Rishi Kothari28.4K views
Debugging Effectively by Colin O'Dell
Debugging EffectivelyDebugging Effectively
Debugging Effectively
Colin O'Dell1.7K views
Introducing Async/Await by Valeri Karpov
Introducing Async/AwaitIntroducing Async/Await
Introducing Async/Await
Valeri Karpov1.2K views
dot net technology by Imran Khan
dot net technologydot net technology
dot net technology
Imran Khan3K views
Angular - Chapter 4 - Data and Event Handling by WebStackAcademy
 Angular - Chapter 4 - Data and Event Handling Angular - Chapter 4 - Data and Event Handling
Angular - Chapter 4 - Data and Event Handling
WebStackAcademy423 views
Spring IO 2023 - Dynamic OpenAPIs with Spring Cloud Gateway by Iván López Martín
Spring IO 2023 - Dynamic OpenAPIs with Spring Cloud GatewaySpring IO 2023 - Dynamic OpenAPIs with Spring Cloud Gateway
Spring IO 2023 - Dynamic OpenAPIs with Spring Cloud Gateway
Automating away bugs with Error Prone in practice - Spring I/O 2023 by Rick Ossendrijver
Automating away bugs with Error Prone in practice - Spring I/O 2023Automating away bugs with Error Prone in practice - Spring I/O 2023
Automating away bugs with Error Prone in practice - Spring I/O 2023
Introduction to Nexus Repository Manager.pdf by Knoldus Inc.
Introduction to Nexus Repository Manager.pdfIntroduction to Nexus Repository Manager.pdf
Introduction to Nexus Repository Manager.pdf
Knoldus Inc.410 views

Similar to Asynchronous programming

No More Deadlocks; Asynchronous Programming in .NET by
No More Deadlocks; Asynchronous Programming in .NETNo More Deadlocks; Asynchronous Programming in .NET
No More Deadlocks; Asynchronous Programming in .NETFilip Ekberg
3.1K views23 slides
オープンデータを使ったモバイルアプリ開発(応用編) by
オープンデータを使ったモバイルアプリ開発(応用編)オープンデータを使ったモバイルアプリ開発(応用編)
オープンデータを使ったモバイルアプリ開発(応用編)Takayuki Goto
142 views28 slides
Think Async: Asynchronous Patterns in NodeJS by
Think Async: Asynchronous Patterns in NodeJSThink Async: Asynchronous Patterns in NodeJS
Think Async: Asynchronous Patterns in NodeJSAdam L Barrett
282 views77 slides
Async Best Practices by
Async Best PracticesAsync Best Practices
Async Best PracticesLluis Franco
4.7K views64 slides
Asynchronní programování by
Asynchronní programováníAsynchronní programování
Asynchronní programováníPeckaDesign.cz
982 views56 slides
NodeJS: the good parts? A skeptic’s view (jax jax2013) by
NodeJS: the good parts? A skeptic’s view (jax jax2013)NodeJS: the good parts? A skeptic’s view (jax jax2013)
NodeJS: the good parts? A skeptic’s view (jax jax2013)Chris Richardson
20.5K views85 slides

Similar to Asynchronous programming(20)

No More Deadlocks; Asynchronous Programming in .NET by Filip Ekberg
No More Deadlocks; Asynchronous Programming in .NETNo More Deadlocks; Asynchronous Programming in .NET
No More Deadlocks; Asynchronous Programming in .NET
Filip Ekberg3.1K views
オープンデータを使ったモバイルアプリ開発(応用編) by Takayuki Goto
オープンデータを使ったモバイルアプリ開発(応用編)オープンデータを使ったモバイルアプリ開発(応用編)
オープンデータを使ったモバイルアプリ開発(応用編)
Takayuki Goto142 views
Think Async: Asynchronous Patterns in NodeJS by Adam L Barrett
Think Async: Asynchronous Patterns in NodeJSThink Async: Asynchronous Patterns in NodeJS
Think Async: Asynchronous Patterns in NodeJS
Adam L Barrett282 views
Async Best Practices by Lluis Franco
Async Best PracticesAsync Best Practices
Async Best Practices
Lluis Franco4.7K views
NodeJS: the good parts? A skeptic’s view (jax jax2013) by Chris Richardson
NodeJS: the good parts? A skeptic’s view (jax jax2013)NodeJS: the good parts? A skeptic’s view (jax jax2013)
NodeJS: the good parts? A skeptic’s view (jax jax2013)
Chris Richardson20.5K views
Expert JavaScript tricks of the masters by Ara Pehlivanian
Expert JavaScript  tricks of the mastersExpert JavaScript  tricks of the masters
Expert JavaScript tricks of the masters
Ara Pehlivanian1.6K views
Workshop: Async and Parallel in C# by Rainer Stropek
Workshop: Async and Parallel in C#Workshop: Async and Parallel in C#
Workshop: Async and Parallel in C#
Rainer Stropek1K views
Durable functions 2.0 (2019-10-10) by Paco de la Cruz
Durable functions 2.0 (2019-10-10)Durable functions 2.0 (2019-10-10)
Durable functions 2.0 (2019-10-10)
Paco de la Cruz443 views
Microsoft 2014 Dev Plataform - Roslyn -& ASP.NET vNext by Rodolfo Finochietti
Microsoft 2014 Dev Plataform -  Roslyn -& ASP.NET vNextMicrosoft 2014 Dev Plataform -  Roslyn -& ASP.NET vNext
Microsoft 2014 Dev Plataform - Roslyn -& ASP.NET vNext
Rodolfo Finochietti4.5K views
Reactive Programming Patterns with RxSwift by Florent Pillet
Reactive Programming Patterns with RxSwiftReactive Programming Patterns with RxSwift
Reactive Programming Patterns with RxSwift
Florent Pillet3.6K views
Asynchronous web apps with the Play Framework 2.0 by Oscar Renalias
Asynchronous web apps with the Play Framework 2.0Asynchronous web apps with the Play Framework 2.0
Asynchronous web apps with the Play Framework 2.0
Oscar Renalias8.2K views
Apache Spark in your likeness - low and high level customization by Bartosz Konieczny
Apache Spark in your likeness - low and high level customizationApache Spark in your likeness - low and high level customization
Apache Spark in your likeness - low and high level customization
Bartosz Konieczny1.2K views
Developing web-apps like it's 2013 by Laurent_VB
Developing web-apps like it's 2013Developing web-apps like it's 2013
Developing web-apps like it's 2013
Laurent_VB3.2K views

More from Filip Ekberg

C# 8 and Beyond by
C# 8 and BeyondC# 8 and Beyond
C# 8 and BeyondFilip Ekberg
1.1K views29 slides
The State of C# by
The State of C#The State of C#
The State of C#Filip Ekberg
333 views26 slides
Building APIs with MVC 6 and OAuth by
Building APIs with MVC 6 and OAuthBuilding APIs with MVC 6 and OAuth
Building APIs with MVC 6 and OAuthFilip Ekberg
2.7K views50 slides
C# Is The Future by
C# Is The FutureC# Is The Future
C# Is The FutureFilip Ekberg
3.7K views48 slides
Asynchronous programming from Xamarin Hakcday in Melbourne by
Asynchronous programming from Xamarin Hakcday in MelbourneAsynchronous programming from Xamarin Hakcday in Melbourne
Asynchronous programming from Xamarin Hakcday in MelbourneFilip Ekberg
778 views19 slides
Azure Mobile Services .NET Backend by
Azure Mobile Services .NET BackendAzure Mobile Services .NET Backend
Azure Mobile Services .NET BackendFilip Ekberg
2.9K views36 slides

More from Filip Ekberg(7)

Building APIs with MVC 6 and OAuth by Filip Ekberg
Building APIs with MVC 6 and OAuthBuilding APIs with MVC 6 and OAuth
Building APIs with MVC 6 and OAuth
Filip Ekberg2.7K views
Asynchronous programming from Xamarin Hakcday in Melbourne by Filip Ekberg
Asynchronous programming from Xamarin Hakcday in MelbourneAsynchronous programming from Xamarin Hakcday in Melbourne
Asynchronous programming from Xamarin Hakcday in Melbourne
Filip Ekberg778 views
Azure Mobile Services .NET Backend by Filip Ekberg
Azure Mobile Services .NET BackendAzure Mobile Services .NET Backend
Azure Mobile Services .NET Backend
Filip Ekberg2.9K views
C# 6.0 - What?! C# is being updated? by Filip Ekberg
C# 6.0 - What?! C# is being updated?C# 6.0 - What?! C# is being updated?
C# 6.0 - What?! C# is being updated?
Filip Ekberg11.5K views

Recently uploaded

Empathic Computing: Delivering the Potential of the Metaverse by
Empathic Computing: Delivering  the Potential of the MetaverseEmpathic Computing: Delivering  the Potential of the Metaverse
Empathic Computing: Delivering the Potential of the MetaverseMark Billinghurst
470 views80 slides
Voice Logger - Telephony Integration Solution at Aegis by
Voice Logger - Telephony Integration Solution at AegisVoice Logger - Telephony Integration Solution at Aegis
Voice Logger - Telephony Integration Solution at AegisNirmal Sharma
17 views1 slide
GDG Cloud Southlake 28 Brad Taylor and Shawn Augenstein Old Problems in the N... by
GDG Cloud Southlake 28 Brad Taylor and Shawn Augenstein Old Problems in the N...GDG Cloud Southlake 28 Brad Taylor and Shawn Augenstein Old Problems in the N...
GDG Cloud Southlake 28 Brad Taylor and Shawn Augenstein Old Problems in the N...James Anderson
33 views32 slides
iSAQB Software Architecture Gathering 2023: How Process Orchestration Increas... by
iSAQB Software Architecture Gathering 2023: How Process Orchestration Increas...iSAQB Software Architecture Gathering 2023: How Process Orchestration Increas...
iSAQB Software Architecture Gathering 2023: How Process Orchestration Increas...Bernd Ruecker
26 views69 slides
The details of description: Techniques, tips, and tangents on alternative tex... by
The details of description: Techniques, tips, and tangents on alternative tex...The details of description: Techniques, tips, and tangents on alternative tex...
The details of description: Techniques, tips, and tangents on alternative tex...BookNet Canada
121 views24 slides
ChatGPT and AI for Web Developers by
ChatGPT and AI for Web DevelopersChatGPT and AI for Web Developers
ChatGPT and AI for Web DevelopersMaximiliano Firtman
181 views82 slides

Recently uploaded(20)

Empathic Computing: Delivering the Potential of the Metaverse by Mark Billinghurst
Empathic Computing: Delivering  the Potential of the MetaverseEmpathic Computing: Delivering  the Potential of the Metaverse
Empathic Computing: Delivering the Potential of the Metaverse
Mark Billinghurst470 views
Voice Logger - Telephony Integration Solution at Aegis by Nirmal Sharma
Voice Logger - Telephony Integration Solution at AegisVoice Logger - Telephony Integration Solution at Aegis
Voice Logger - Telephony Integration Solution at Aegis
Nirmal Sharma17 views
GDG Cloud Southlake 28 Brad Taylor and Shawn Augenstein Old Problems in the N... by James Anderson
GDG Cloud Southlake 28 Brad Taylor and Shawn Augenstein Old Problems in the N...GDG Cloud Southlake 28 Brad Taylor and Shawn Augenstein Old Problems in the N...
GDG Cloud Southlake 28 Brad Taylor and Shawn Augenstein Old Problems in the N...
James Anderson33 views
iSAQB Software Architecture Gathering 2023: How Process Orchestration Increas... by Bernd Ruecker
iSAQB Software Architecture Gathering 2023: How Process Orchestration Increas...iSAQB Software Architecture Gathering 2023: How Process Orchestration Increas...
iSAQB Software Architecture Gathering 2023: How Process Orchestration Increas...
Bernd Ruecker26 views
The details of description: Techniques, tips, and tangents on alternative tex... by BookNet Canada
The details of description: Techniques, tips, and tangents on alternative tex...The details of description: Techniques, tips, and tangents on alternative tex...
The details of description: Techniques, tips, and tangents on alternative tex...
BookNet Canada121 views
Spesifikasi Lengkap ASUS Vivobook Go 14 by Dot Semarang
Spesifikasi Lengkap ASUS Vivobook Go 14Spesifikasi Lengkap ASUS Vivobook Go 14
Spesifikasi Lengkap ASUS Vivobook Go 14
Dot Semarang35 views
Automating a World-Class Technology Conference; Behind the Scenes of CiscoLive by Network Automation Forum
Automating a World-Class Technology Conference; Behind the Scenes of CiscoLiveAutomating a World-Class Technology Conference; Behind the Scenes of CiscoLive
Automating a World-Class Technology Conference; Behind the Scenes of CiscoLive
Transcript: The Details of Description Techniques tips and tangents on altern... by BookNet Canada
Transcript: The Details of Description Techniques tips and tangents on altern...Transcript: The Details of Description Techniques tips and tangents on altern...
Transcript: The Details of Description Techniques tips and tangents on altern...
BookNet Canada130 views
handbook for web 3 adoption.pdf by Liveplex
handbook for web 3 adoption.pdfhandbook for web 3 adoption.pdf
handbook for web 3 adoption.pdf
Liveplex19 views
Perth MeetUp November 2023 by Michael Price
Perth MeetUp November 2023 Perth MeetUp November 2023
Perth MeetUp November 2023
Michael Price15 views
AMAZON PRODUCT RESEARCH.pdf by JerikkLaureta
AMAZON PRODUCT RESEARCH.pdfAMAZON PRODUCT RESEARCH.pdf
AMAZON PRODUCT RESEARCH.pdf
JerikkLaureta15 views
Piloting & Scaling Successfully With Microsoft Viva by Richard Harbridge
Piloting & Scaling Successfully With Microsoft VivaPiloting & Scaling Successfully With Microsoft Viva
Piloting & Scaling Successfully With Microsoft Viva
Data-centric AI and the convergence of data and model engineering: opportunit... by Paolo Missier
Data-centric AI and the convergence of data and model engineering:opportunit...Data-centric AI and the convergence of data and model engineering:opportunit...
Data-centric AI and the convergence of data and model engineering: opportunit...
Paolo Missier34 views
Five Things You SHOULD Know About Postman by Postman
Five Things You SHOULD Know About PostmanFive Things You SHOULD Know About Postman
Five Things You SHOULD Know About Postman
Postman27 views
Case Study Copenhagen Energy and Business Central.pdf by Aitana
Case Study Copenhagen Energy and Business Central.pdfCase Study Copenhagen Energy and Business Central.pdf
Case Study Copenhagen Energy and Business Central.pdf
Aitana12 views

Asynchronous programming