Suche senden
Hochladen
rioinfo2012
•
0 gefällt mir
•
899 views
Juan Lopes
Folgen
PROGRAMAÇÃO ASSÍNCRONA EM .NET 4.5
Weniger lesen
Mehr lesen
Technologie
News & Politik
Melden
Teilen
Melden
Teilen
1 von 53
Jetzt herunterladen
Downloaden Sie, um offline zu lesen
Empfohlen
Release with confidence
Release with confidence
John Congdon
SDPHP - Percona Toolkit (It's Basically Magic)
SDPHP - Percona Toolkit (It's Basically Magic)
Robert Swisher
Cse 241
Cse 241
vaminorc
WebSockets with PHP: Mission impossible
WebSockets with PHP: Mission impossible
Yoan-Alexander Grigorov
Controlling multiple VMs with the power of Python
Controlling multiple VMs with the power of Python
Yurii Vasylenko
Fixing 403 Forbidden Nginx Errors
Fixing 403 Forbidden Nginx Errors
VEXXHOST Private Cloud
Real Time Web Applications and Merb
Real Time Web Applications and Merb
Collin Miller
Socket programming with php
Socket programming with php
Elizabeth Smith
Weitere ähnliche Inhalte
Was ist angesagt?
Think your software is fault-tolerant? Prove it!
Think your software is fault-tolerant? Prove it!
Christopher Batey
Flask With Server-Sent Event
Flask With Server-Sent Event
Tencent
Why async matters
Why async matters
timbc
Async-await best practices in 10 minutes
Async-await best practices in 10 minutes
Paulo Morgado
Process file one after another
Process file one after another
Anirban Sen Chowdhary
Domains!
Domains!
Domenic Denicola
JDO 2019: Serverless Hype Driven Development - Grzegorz Piotrowski
JDO 2019: Serverless Hype Driven Development - Grzegorz Piotrowski
PROIDEA
Implement server push in flask framework
Implement server push in flask framework
Chi-Chia Huang
What's new on Laravel 5.5
What's new on Laravel 5.5
Glend Maatita
Nginx for Fun & Performance - Philipp Krenn - Codemotion Rome 2015
Nginx for Fun & Performance - Philipp Krenn - Codemotion Rome 2015
Codemotion
Sinatra: прошлое, будущее и настоящее
Sinatra: прошлое, будущее и настоящее
.toster
Jones_Lamp_Tutorial
Jones_Lamp_Tutorial
Olivia J. Jones
Christian Strappazzon - Presentazione Python Milano - Codemotion Milano 2017
Christian Strappazzon - Presentazione Python Milano - Codemotion Milano 2017
Codemotion
Debugging PHP With Xdebug
Debugging PHP With Xdebug
Mark Niebergall
Firewall filters
Firewall filters
privado
Python Programming Essentials - M22 - File Operations
Python Programming Essentials - M22 - File Operations
P3 InfoTech Solutions Pvt. Ltd.
Push the web with HTML5
Push the web with HTML5
Stoyan Zhekov
Docker perl build
Docker perl build
Workhorse Computing
Syncing up with Python’s asyncio for (micro) service development, Joir-dan Gumbs
Syncing up with Python’s asyncio for (micro) service development, Joir-dan Gumbs
Pôle Systematic Paris-Region
Assurer - a pluggable server testing/monitoring framework
Assurer - a pluggable server testing/monitoring framework
Gosuke Miyashita
Was ist angesagt?
(20)
Think your software is fault-tolerant? Prove it!
Think your software is fault-tolerant? Prove it!
Flask With Server-Sent Event
Flask With Server-Sent Event
Why async matters
Why async matters
Async-await best practices in 10 minutes
Async-await best practices in 10 minutes
Process file one after another
Process file one after another
Domains!
Domains!
JDO 2019: Serverless Hype Driven Development - Grzegorz Piotrowski
JDO 2019: Serverless Hype Driven Development - Grzegorz Piotrowski
Implement server push in flask framework
Implement server push in flask framework
What's new on Laravel 5.5
What's new on Laravel 5.5
Nginx for Fun & Performance - Philipp Krenn - Codemotion Rome 2015
Nginx for Fun & Performance - Philipp Krenn - Codemotion Rome 2015
Sinatra: прошлое, будущее и настоящее
Sinatra: прошлое, будущее и настоящее
Jones_Lamp_Tutorial
Jones_Lamp_Tutorial
Christian Strappazzon - Presentazione Python Milano - Codemotion Milano 2017
Christian Strappazzon - Presentazione Python Milano - Codemotion Milano 2017
Debugging PHP With Xdebug
Debugging PHP With Xdebug
Firewall filters
Firewall filters
Python Programming Essentials - M22 - File Operations
Python Programming Essentials - M22 - File Operations
Push the web with HTML5
Push the web with HTML5
Docker perl build
Docker perl build
Syncing up with Python’s asyncio for (micro) service development, Joir-dan Gumbs
Syncing up with Python’s asyncio for (micro) service development, Joir-dan Gumbs
Assurer - a pluggable server testing/monitoring framework
Assurer - a pluggable server testing/monitoring framework
Andere mochten auch
qconsp2015
qconsp2015
Juan Lopes
qconrio2015
qconrio2015
Juan Lopes
tdc2012
tdc2012
Juan Lopes
uerj201212
uerj201212
Juan Lopes
dnarj-20120630
dnarj-20120630
Juan Lopes
dnarj20130504
dnarj20130504
Juan Lopes
PIPES: Uma linguagem para processamento distribuído de eventos complexos
PIPES: Uma linguagem para processamento distribuído de eventos complexos
Juan Lopes
Andere mochten auch
(7)
qconsp2015
qconsp2015
qconrio2015
qconrio2015
tdc2012
tdc2012
uerj201212
uerj201212
dnarj-20120630
dnarj-20120630
dnarj20130504
dnarj20130504
PIPES: Uma linguagem para processamento distribuído de eventos complexos
PIPES: Uma linguagem para processamento distribuído de eventos complexos
Ähnlich wie rioinfo2012
About Node.js
About Node.js
Artemisa Yescas Engler
Node.js: CAMTA Presentation
Node.js: CAMTA Presentation
Rob Tweed
Fighting Fear-Driven-Development With PHPUnit
Fighting Fear-Driven-Development With PHPUnit
James Fuller
Everything you wanted to know about writing async, concurrent http apps in java
Everything you wanted to know about writing async, concurrent http apps in java
Baruch Sadogursky
Node intro
Node intro
cloudhead
Introduction to PowerShell
Introduction to PowerShell
Boulos Dib
Binary Studio Academy: Concurrency in C# 5.0
Binary Studio Academy: Concurrency in C# 5.0
Binary Studio
Node.js - async for the rest of us.
Node.js - async for the rest of us.
Mike Brevoort
RichFaces - Testing on Mobile Devices
RichFaces - Testing on Mobile Devices
Pavol Pitoňák
Breaking Parser Logic: Take Your Path Normalization Off and Pop 0days Out!
Breaking Parser Logic: Take Your Path Normalization Off and Pop 0days Out!
Priyanka Aash
The GO Language : From Beginners to Gophers
The GO Language : From Beginners to Gophers
Alessandro Sanino
Programming language for the cloud infrastructure
Programming language for the cloud infrastructure
Yaroslav Muravskyi
201209 tech days .net 4.5 核心功能及綜覽
201209 tech days .net 4.5 核心功能及綜覽
Meng-Ru (Raymond) Tsai
Async and Await on the Server
Async and Await on the Server
Doug Jones
Torquebox OSCON Java 2011
Torquebox OSCON Java 2011
tobiascrawley
End to-end async and await
End to-end async and await
vfabro
Seven perilous pitfalls to avoid with Java | DevNation Tech Talk
Seven perilous pitfalls to avoid with Java | DevNation Tech Talk
Red Hat Developers
Callbacks, Promises, and Coroutines (oh my!): Asynchronous Programming Patter...
Callbacks, Promises, and Coroutines (oh my!): Asynchronous Programming Patter...
Domenic Denicola
Play Framework: async I/O with Java and Scala
Play Framework: async I/O with Java and Scala
Yevgeniy Brikman
Developing IT infrastructures with Puppet
Developing IT infrastructures with Puppet
Alessandro Franceschi
Ähnlich wie rioinfo2012
(20)
About Node.js
About Node.js
Node.js: CAMTA Presentation
Node.js: CAMTA Presentation
Fighting Fear-Driven-Development With PHPUnit
Fighting Fear-Driven-Development With PHPUnit
Everything you wanted to know about writing async, concurrent http apps in java
Everything you wanted to know about writing async, concurrent http apps in java
Node intro
Node intro
Introduction to PowerShell
Introduction to PowerShell
Binary Studio Academy: Concurrency in C# 5.0
Binary Studio Academy: Concurrency in C# 5.0
Node.js - async for the rest of us.
Node.js - async for the rest of us.
RichFaces - Testing on Mobile Devices
RichFaces - Testing on Mobile Devices
Breaking Parser Logic: Take Your Path Normalization Off and Pop 0days Out!
Breaking Parser Logic: Take Your Path Normalization Off and Pop 0days Out!
The GO Language : From Beginners to Gophers
The GO Language : From Beginners to Gophers
Programming language for the cloud infrastructure
Programming language for the cloud infrastructure
201209 tech days .net 4.5 核心功能及綜覽
201209 tech days .net 4.5 核心功能及綜覽
Async and Await on the Server
Async and Await on the Server
Torquebox OSCON Java 2011
Torquebox OSCON Java 2011
End to-end async and await
End to-end async and await
Seven perilous pitfalls to avoid with Java | DevNation Tech Talk
Seven perilous pitfalls to avoid with Java | DevNation Tech Talk
Callbacks, Promises, and Coroutines (oh my!): Asynchronous Programming Patter...
Callbacks, Promises, and Coroutines (oh my!): Asynchronous Programming Patter...
Play Framework: async I/O with Java and Scala
Play Framework: async I/O with Java and Scala
Developing IT infrastructures with Puppet
Developing IT infrastructures with Puppet
Kürzlich hochgeladen
Cybersecurity Workshop #1.pptx
Cybersecurity Workshop #1.pptx
GDSC PJATK
Designing A Time bound resource download URL
Designing A Time bound resource download URL
Runcy Oommen
Apres-Cyber - The Data Dilemma: Bridging Offensive Operations and Machine Lea...
Apres-Cyber - The Data Dilemma: Bridging Offensive Operations and Machine Lea...
Will Schroeder
IESVE Software for Florida Code Compliance Using ASHRAE 90.1-2019
IESVE Software for Florida Code Compliance Using ASHRAE 90.1-2019
IES VE
COMPUTER 10: Lesson 7 - File Storage and Online Collaboration
COMPUTER 10: Lesson 7 - File Storage and Online Collaboration
bruanjhuli
Using IESVE for Loads, Sizing and Heat Pump Modeling to Achieve Decarbonization
Using IESVE for Loads, Sizing and Heat Pump Modeling to Achieve Decarbonization
IES VE
9 Steps For Building Winning Founding Team
9 Steps For Building Winning Founding Team
Adam Moalla
IaC & GitOps in a Nutshell - a FridayInANuthshell Episode.pdf
IaC & GitOps in a Nutshell - a FridayInANuthshell Episode.pdf
Daniel Santiago Silva Capera
Crea il tuo assistente AI con lo Stregatto (open source python framework)
Crea il tuo assistente AI con lo Stregatto (open source python framework)
Commit University
UiPath Solutions Management Preview - Northern CA Chapter - March 22.pdf
UiPath Solutions Management Preview - Northern CA Chapter - March 22.pdf
DianaGray10
NIST Cybersecurity Framework (CSF) 2.0 Workshop
NIST Cybersecurity Framework (CSF) 2.0 Workshop
Bachir Benyammi
20230202 - Introduction to tis-py
20230202 - Introduction to tis-py
Jamie (Taka) Wang
Introduction to Matsuo Laboratory (ENG).pptx
Introduction to Matsuo Laboratory (ENG).pptx
Matsuo Lab
Artificial Intelligence & SEO Trends for 2024
Artificial Intelligence & SEO Trends for 2024
D Cloud Solutions
How Accurate are Carbon Emissions Projections?
How Accurate are Carbon Emissions Projections?
IES VE
Nanopower In Semiconductor Industry.pdf
Nanopower In Semiconductor Industry.pdf
Pedro Manuel
Bird eye's view on Camunda open source ecosystem
Bird eye's view on Camunda open source ecosystem
Asko Soukka
UWB Technology for Enhanced Indoor and Outdoor Positioning in Physiological M...
UWB Technology for Enhanced Indoor and Outdoor Positioning in Physiological M...
UbiTrack UK
AI You Can Trust - Ensuring Success with Data Integrity Webinar
AI You Can Trust - Ensuring Success with Data Integrity Webinar
Precisely
Comparing Sidecar-less Service Mesh from Cilium and Istio
Comparing Sidecar-less Service Mesh from Cilium and Istio
Christian Posta
Kürzlich hochgeladen
(20)
Cybersecurity Workshop #1.pptx
Cybersecurity Workshop #1.pptx
Designing A Time bound resource download URL
Designing A Time bound resource download URL
Apres-Cyber - The Data Dilemma: Bridging Offensive Operations and Machine Lea...
Apres-Cyber - The Data Dilemma: Bridging Offensive Operations and Machine Lea...
IESVE Software for Florida Code Compliance Using ASHRAE 90.1-2019
IESVE Software for Florida Code Compliance Using ASHRAE 90.1-2019
COMPUTER 10: Lesson 7 - File Storage and Online Collaboration
COMPUTER 10: Lesson 7 - File Storage and Online Collaboration
Using IESVE for Loads, Sizing and Heat Pump Modeling to Achieve Decarbonization
Using IESVE for Loads, Sizing and Heat Pump Modeling to Achieve Decarbonization
9 Steps For Building Winning Founding Team
9 Steps For Building Winning Founding Team
IaC & GitOps in a Nutshell - a FridayInANuthshell Episode.pdf
IaC & GitOps in a Nutshell - a FridayInANuthshell Episode.pdf
Crea il tuo assistente AI con lo Stregatto (open source python framework)
Crea il tuo assistente AI con lo Stregatto (open source python framework)
UiPath Solutions Management Preview - Northern CA Chapter - March 22.pdf
UiPath Solutions Management Preview - Northern CA Chapter - March 22.pdf
NIST Cybersecurity Framework (CSF) 2.0 Workshop
NIST Cybersecurity Framework (CSF) 2.0 Workshop
20230202 - Introduction to tis-py
20230202 - Introduction to tis-py
Introduction to Matsuo Laboratory (ENG).pptx
Introduction to Matsuo Laboratory (ENG).pptx
Artificial Intelligence & SEO Trends for 2024
Artificial Intelligence & SEO Trends for 2024
How Accurate are Carbon Emissions Projections?
How Accurate are Carbon Emissions Projections?
Nanopower In Semiconductor Industry.pdf
Nanopower In Semiconductor Industry.pdf
Bird eye's view on Camunda open source ecosystem
Bird eye's view on Camunda open source ecosystem
UWB Technology for Enhanced Indoor and Outdoor Positioning in Physiological M...
UWB Technology for Enhanced Indoor and Outdoor Positioning in Physiological M...
AI You Can Trust - Ensuring Success with Data Integrity Webinar
AI You Can Trust - Ensuring Success with Data Integrity Webinar
Comparing Sidecar-less Service Mesh from Cilium and Istio
Comparing Sidecar-less Service Mesh from Cilium and Istio
rioinfo2012
1.
PROGRAMAÇÃO CONCORRENTE EM .NET 4.5 JUAN
LOPES twitter.com/juanplopes github.com/juanplopes
2.
PROGRAMAÇÃO TALVEZ CONCORRENTE EM .NET
4.5 JUAN LOPES twitter.com/juanplopes github.com/juanplopes
3.
PROGRAMAÇÃO ASSÍNCRONA EM .NET 4.5 JUAN
LOPES twitter.com/juanplopes github.com/juanplopes
4.
EU PROGRAMO WEB
5.
EU PROGRAMO WEB POR
QUE PROGRAMAR ASSINCRONAMENTE?
6.
EU PROGRAMO WEB POR
QUE PROGRAMAR ASSINCRONAMENTE? MENOR LATÊNCIA MAIOR RESPONSIVIDADE
7.
WINDOWS XP WINDOWS FORMS NÃO
BLOQUEIE A THREAD DA UI
8.
WINDOWS 8
WINRT NÃO BLOQUEIE A THREAD DA UI
9.
I/O vs CPU
10.
I/O vs CPU I/O
É MAIS CARO
11.
I/O vs CPU I/O
É MAIS LENTO
12.
I/O vs CPU I/O
É MAIS LENTO DISCO REDE BANCO DE DADOS
13.
PROGRAMAÇÃO CONCORRENTE
14.
PROGRAMAÇÃO CONCORRENTE THREADS
15.
PROGRAMAÇÃO CONCORRENTE É
DIFÍCIL
16.
PROGRAMAÇÃO CONCORRENTE É
DIFÍCIL OU NÃO
17.
COMO NÃO FAZER: new
Thread(() => { //código lento }).Start();
18.
TALVEZ NÃO PROGRAMAR
CONCORRENTEMENTE?
19.
TALVEZ NÃO PROGRAMAR
CONCORRENTEMENTE? TALVEZ ASSINCRONAMENTE
20.
MAS ANTES, O QUE
TEMOS HOJE?
21.
ATÉ .NET 3.5 BeginInvoke
EndInvoke
22.
Func<string> ler =
() => File.ReadAllText(@"C:test.txt"); var handle = ler.BeginInvoke(null, null); //qualquer outro código var resultado = ler.EndInvoke(handle);
23.
var req =
WebRequest.Create("http://google.com"); var handle = req.BeginGetRequestStream(null, null); //qualquer código var stream = req.EndGetRequestStream(handle);
24.
ATÉ .NET 3.5 Begin[QualquerCoisa]
End[QualquerCoisa]
25.
ATÉ .NET 3.5 Begin[QualquerCoisa]
End[QualquerCoisa] THREADS RACE CONDITIONS MAIS COMPLICADO
26.
.NET 4.0 PARALLEL EXTENSIONS
PLINQ (Parallel LINQ) + TPL (Task Parallel Library)
27.
.NET 4.0 PLINQ (Parallel
LINQ)
28.
var files =
new[] {"file1.txt", "file2.txt"}; var contents = string.Join("", files .AsParallel() .Select(File.ReadAllText) .ToArray());
29.
.NET 4.0 TPL (Task
Parallel Library)
30.
.NET 4.0 TPL (Task
Parallel Library) Task<T>
31.
var task =
Task.Run(() => File.ReadAllText(@"C:test.txt")); //qualquer outro código var resultado = task.Result;
32.
.NET 4.0 TPL (Task
Parallel Library) THREADS RACE CONDITIONS MENOS COMPLICADO
33.
.NET 4.5 ASYNC
AWAIT
34.
fs.readFile('test.txt', function (err,
data) { if (err) throw err; console.log(data); });
35.
Task.Run(() => File.ReadAllText(@"test.txt"))
.ContinueWith(x => Console.WriteLine(x.Result));
36.
var task =
Task.Run(() => File.ReadAllText(@"test.txt")); task.ContinueWith(x => Console.WriteLine(x.Result));
37.
var task =
Task.Run(() => File.ReadAllText(@"test.txt")); Console.WriteLine(await task);
38.
static async Task<int>
GoogleMaisYahoo() { var http = new HttpClient(); var google = http.GetStringAsync("http://google.com"); var yahoo = http.GetStringAsync("http://yahoo.com"); return (await google).Length + (await yahoo).Length; } static void Main(string[] args) { var task = GooglePlusYahoo(); //qualquer código Console.WriteLine(task.Result); Console.ReadLine(); }
39.
static Task<int> GooglePlusYahoo() {
var http = new HttpClient(); var google = http.GetStringAsync("http://google.com"); var yahoo = http.GetStringAsync("http://yahoo.com"); return Task.WhenAll(google, yahoo) .ContinueWith(x => x.Result[0].Length + x.Result[1].Length); } static void Main(string[] args) { var task = GooglePlusYahoo(); //qualquer código Console.WriteLine(task.Result); Console.ReadLine(); }
40.
.NET 4.5
ASYNC AWAIT SEM THREADS SEM RACE CONDITIONS MUITO MENOS COMPLICADO
41.
RESOLVE 92.4242% DOS
PROBLEMAS QUE THREADS RESOLVEM, APROXIMADAMENTE
43.
private async void
button1_Click(object sender, EventArgs e) { var http = new HttpClient(); page.Text = "Loading..."; page.Text = await http.GetStringAsync("http://google.com"); }
44.
MESMA THREAD QUE
CHAMOU O MÉTODO POTENCIALMENTE NOVA THREAD private async void button1_Click(object sender, EventArgs e) { var http = new HttpClient(); page.Text = "Loading..."; page.Text = await http.GetStringAsync("http://google.com"); }
45.
ENTÃO CONTINUAMOS
COM THREADS BLOQUEADAS EM I/O?
46.
ENTÃO CONTINUAMOS
COM THREADS BLOQUEADAS EM I/O? NÃO
47.
IOCP
48.
IOCP I/O COMPLETION PORTS FUNCIONALIDADE
DO S.O. ASYNC "THREADLESS" I/O
49.
NÃO HÁ THREADS BLOQUEADAS
ESPERANDO CADA I/O TERMINAR
50.
NÃO HÁ THREADS BLOQUEADAS
ESPERANDO CADA I/O TERMINAR HÁ UMA ÚNICA THREAD DE IO QUE LÊ UMA FILA
51.
MÉTODOS DA BCL
QUE TERMINAM COM "ASYNC", GERALMENTE USAM IOCP
52.
MÉTODOS DA BCL
QUE TERMINAM COM "ASYNC", GERALMENTE USAM IOCP FileStream#ReadAsync HttpClient#GetStringAsync Socket#SendAsync
53.
OBRIGADO! TWITTER.COM/JUANPLOPES GITHUB.COM/JUANPLOPES
Jetzt herunterladen