This document provides a guide to debugging asynchronous code in .NET. It discusses how asynchronous code uses an "async logical call stack" instead of physical threads. It demonstrates how the debugger can show this async call stack to understand the flow of async methods. It also shows how tasks, threads, and exceptions are handled in async code and tips for writing asynchronous code that is easier to debug.
Async Debugging - A Practical Guide to survive !Mirco Vanini
Â
The speech talk about the specialised tools inside visual studio to survive from async code bugs with special look about how to write a right async code
Hector v2: The Second Version of the Popular High-Level Java Client for Apach...zznate
Â
This presentation will provide a preview of our new high-level API designed around community feedback and built on the solid foundation of Hector client internals currently in use by a number of production systems. A brief introduction to the existing Hector client will be included to accomadate new users.
In the “Sharing is caring” spirit, we came up with a series of internal talks called, By Showmaxers, for Showmaxers, and we recently started making them public. There are already talks about Networks, and Android app building, available.
Our latest talk focuses on PostgreSQL Terminology, and is led by Angus Dippenaar. He worked on Showmax projects from South Africa, and moved to work with us in Prague, Czech Republic.
The talk was meant to fill some holes in our knowledge of PostgreSQL. So, it guides you through the basic PostgreSQL terminology you need to understand when reading the official documentation and blogs.
You may learn what all these POstgreSQL terms mean:
Command, query, local or global object, non-schema local objects, relation, tablespace, database, database cluster, instance and its processes like postmaster or backend; session, connection, heap, file segment, table, TOAST, tuple, view, materialized (view), transaction, commit, rollback, index, write-ahead log, WAL record, WAL file, checkpoint, Multi-version concurrency control (MVCC), dead tuples (dead rows), or transaction exhaustion.
The terminology is followed by a demonstration of transaction exhaustion.
Get the complete explanation and see the demonstration of the transaction exhaustion and of tuple freezing in the talk on YouTube: https://youtu.be/E-RkI3Ws7gM.
Async Debugging - A Practical Guide to survive !Mirco Vanini
Â
The speech talk about the specialised tools inside visual studio to survive from async code bugs with special look about how to write a right async code
Hector v2: The Second Version of the Popular High-Level Java Client for Apach...zznate
Â
This presentation will provide a preview of our new high-level API designed around community feedback and built on the solid foundation of Hector client internals currently in use by a number of production systems. A brief introduction to the existing Hector client will be included to accomadate new users.
In the “Sharing is caring” spirit, we came up with a series of internal talks called, By Showmaxers, for Showmaxers, and we recently started making them public. There are already talks about Networks, and Android app building, available.
Our latest talk focuses on PostgreSQL Terminology, and is led by Angus Dippenaar. He worked on Showmax projects from South Africa, and moved to work with us in Prague, Czech Republic.
The talk was meant to fill some holes in our knowledge of PostgreSQL. So, it guides you through the basic PostgreSQL terminology you need to understand when reading the official documentation and blogs.
You may learn what all these POstgreSQL terms mean:
Command, query, local or global object, non-schema local objects, relation, tablespace, database, database cluster, instance and its processes like postmaster or backend; session, connection, heap, file segment, table, TOAST, tuple, view, materialized (view), transaction, commit, rollback, index, write-ahead log, WAL record, WAL file, checkpoint, Multi-version concurrency control (MVCC), dead tuples (dead rows), or transaction exhaustion.
The terminology is followed by a demonstration of transaction exhaustion.
Get the complete explanation and see the demonstration of the transaction exhaustion and of tuple freezing in the talk on YouTube: https://youtu.be/E-RkI3Ws7gM.
Reactive Programming, Traits and Principles. What is Reactive, where does it come from, and what is it good for? How does it differ from event driven programming? It only functional?
Asynchronous, Event-driven Network Application Development with NettyErsin Er
Â
"Asynchronous, Event-driven Network Application Development with Netty" presented at Ankara JUG in 2015, June.
The presentation starts with motivations for Non-Blocking I/O and continues with general overview of NIO and Netty. The actual talk was supplied with Netty's own examples.
Find out how to build decentralized, fault-tolerant, stateful application services using core concepts and techniques from the Amazon Dynamo paper using riak_core as a toolkit.
Better Open Source Enterprise C++ Web ServicesWSO2
Â
In this webinar/presentation presented on November 10, 2009, Nandika Jayawardana explores the capabilities of the WSO2 Web Services Framework for C++ (WSO2 WSF/C++) to develop and deploy Web services in C++.
Apache Flink Internals: Stream & Batch Processing in One System – Apache Flin...ucelebi
Â
An in-depth look at Apache Flink’s Streaming Dataflow Engine. Flink executes data streaming programs directly as streams with low latency and flexible user-defined state and models batch programs as streaming programs on finite data streams.
The slides cover the general design of the runtime and show how the engine is able to support diverse features and workloads without compromising on performance or usability.
Flink Forward, Berlin
October 13, 2015
Blocks is a cool concept and is very much needed for performance improvements and responsiveness. GCD helps run blocks effortlessly by scheduling on a desired queue, priority and lots more.
The model/view design pattern is the standard way of separating UI from business logic, especially when the data exchanged is dynamic. In a series of blog posts released in May, we presented an introduction to model/view design and provided an example of how this pattern is leveraged in Qt applications. In this webinar, we will go more in depth, illustrating model/view with a set of two QML programming examples. The first will consider the simple case where data size remains constant. The second will cover the more common situation where data size is dynamic.
Reactive Programming, Traits and Principles. What is Reactive, where does it come from, and what is it good for? How does it differ from event driven programming? It only functional?
Asynchronous, Event-driven Network Application Development with NettyErsin Er
Â
"Asynchronous, Event-driven Network Application Development with Netty" presented at Ankara JUG in 2015, June.
The presentation starts with motivations for Non-Blocking I/O and continues with general overview of NIO and Netty. The actual talk was supplied with Netty's own examples.
Find out how to build decentralized, fault-tolerant, stateful application services using core concepts and techniques from the Amazon Dynamo paper using riak_core as a toolkit.
Better Open Source Enterprise C++ Web ServicesWSO2
Â
In this webinar/presentation presented on November 10, 2009, Nandika Jayawardana explores the capabilities of the WSO2 Web Services Framework for C++ (WSO2 WSF/C++) to develop and deploy Web services in C++.
Apache Flink Internals: Stream & Batch Processing in One System – Apache Flin...ucelebi
Â
An in-depth look at Apache Flink’s Streaming Dataflow Engine. Flink executes data streaming programs directly as streams with low latency and flexible user-defined state and models batch programs as streaming programs on finite data streams.
The slides cover the general design of the runtime and show how the engine is able to support diverse features and workloads without compromising on performance or usability.
Flink Forward, Berlin
October 13, 2015
Blocks is a cool concept and is very much needed for performance improvements and responsiveness. GCD helps run blocks effortlessly by scheduling on a desired queue, priority and lots more.
The model/view design pattern is the standard way of separating UI from business logic, especially when the data exchanged is dynamic. In a series of blog posts released in May, we presented an introduction to model/view design and provided an example of how this pattern is leveraged in Qt applications. In this webinar, we will go more in depth, illustrating model/view with a set of two QML programming examples. The first will consider the simple case where data size remains constant. The second will cover the more common situation where data size is dynamic.
A presentation for the Reactive Programming Enthusiasts Denver meet-up.
http://www.meetup.com/Reactive-Programming-Enthusiasts-Denver/
How Reactive Mongo helps utilize your hardware better and achieve a non-blocking application from the bottom up.
Programming Sideways: Asynchronous Techniques for AndroidEmanuele Di Saverio
Â
Android apps need to respond fast, support highly parallel execution and multi component architecture.
Learn some tricks of the trade for these problems!
as presented at www.mobileconference.it (2013 edition)
NDC Sydney 2019 - Async Demystified -- Karel ZikmundKarel Zikmund
Â
NDC Sydney 2019 conference in Sydney, AU - 2019/10/15
Talk: War stories from .NET team by Karel Zikmund
https://sessionize.com/s/karel-zikmund/async-demystified/24175
https://www.youtube.com/watch?v=TgUYcZV-foM
Think Async: Asynchronous Patterns in NodeJSAdam L Barrett
Â
JavaScript is single threaded, so understanding the async patterns available in the language is critical to creating maintainable NodeJS applications with good performance. In order to master “thinking in async”, we’ll explore the async patterns available in node and JavaScript including standard callbacks, promises, thunks/tasks, the new async/await, the upcoming asynchronous iteration features, streams, CSP and ES Observables.
In a world where microservices are more and more a standard architecture for Java based applications running in the cloud, the JVM warmup time can become a limitation. Especially when you look at spinning up new instances of an app as response to changes in load, the warmup time can be a problem. Native images are one solution to solve these problems because their statically ahead of time compiled code simply doesn’t have to warmup and so has short startup time. But even with the shorter startup time and smaller footprint it doesn’t come without a drawback. The overall performance might be slower because of the missing JIT optimizations at runtime. There is a new OpenJDK project called CRaC (Coordinated Restore at Checkpoint) which goal it is to address the JVM warmup problem with a different approach. The idea is to take a snapshot of the running JVM, store it in files and restore the JVM at a later point in time (or even on another machine).
This session will give you a short overview of the CRaC project and shows some results from a proof of concept implementation.
An introduction about how to migration from .NET Full FW to .NET Core 3.0 for your WPF & Windows Forms applications and the incrementally modernizing with Windows 10 features
GridMate - End to end testing is a critical piece to ensure quality and avoid...ThomasParaiso2
Â
End to end testing is a critical piece to ensure quality and avoid regressions. In this session, we share our journey building an E2E testing pipeline for GridMate components (LWC and Aura) using Cypress, JSForce, FakerJS…
Generative AI Deep Dive: Advancing from Proof of Concept to ProductionAggregage
Â
Join Maher Hanafi, VP of Engineering at Betterworks, in this new session where he'll share a practical framework to transform Gen AI prototypes into impactful products! He'll delve into the complexities of data collection and management, model selection and optimization, and ensuring security, scalability, and responsible use.
The Art of the Pitch: WordPress Relationships and SalesLaura Byrne
Â
Clients don’t know what they don’t know. What web solutions are right for them? How does WordPress come into the picture? How do you make sure you understand scope and timeline? What do you do if sometime changes?
All these questions and more will be explored as we talk about matching clients’ needs with what your agency offers without pulling teeth or pulling your hair out. Practical tips, and strategies for successful relationship building that leads to closing the deal.
Pushing the limits of ePRTC: 100ns holdover for 100 daysAdtran
Â
At WSTS 2024, Alon Stern explored the topic of parametric holdover and explained how recent research findings can be implemented in real-world PNT networks to achieve 100 nanoseconds of accuracy for up to 100 days.
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Albert Hoitingh
Â
In this session I delve into the encryption technology used in Microsoft 365 and Microsoft Purview. Including the concepts of Customer Key and Double Key Encryption.
GraphRAG is All You need? LLM & Knowledge GraphGuy Korland
Â
Guy Korland, CEO and Co-founder of FalkorDB, will review two articles on the integration of language models with knowledge graphs.
1. Unifying Large Language Models and Knowledge Graphs: A Roadmap.
https://arxiv.org/abs/2306.08302
2. Microsoft Research's GraphRAG paper and a review paper on various uses of knowledge graphs:
https://www.microsoft.com/en-us/research/blog/graphrag-unlocking-llm-discovery-on-narrative-private-data/
Enchancing adoption of Open Source Libraries. A case study on Albumentations.AIVladimir Iglovikov, Ph.D.
Â
Presented by Vladimir Iglovikov:
- https://www.linkedin.com/in/iglovikov/
- https://x.com/viglovikov
- https://www.instagram.com/ternaus/
This presentation delves into the journey of Albumentations.ai, a highly successful open-source library for data augmentation.
Created out of a necessity for superior performance in Kaggle competitions, Albumentations has grown to become a widely used tool among data scientists and machine learning practitioners.
This case study covers various aspects, including:
People: The contributors and community that have supported Albumentations.
Metrics: The success indicators such as downloads, daily active users, GitHub stars, and financial contributions.
Challenges: The hurdles in monetizing open-source projects and measuring user engagement.
Development Practices: Best practices for creating, maintaining, and scaling open-source libraries, including code hygiene, CI/CD, and fast iteration.
Community Building: Strategies for making adoption easy, iterating quickly, and fostering a vibrant, engaged community.
Marketing: Both online and offline marketing tactics, focusing on real, impactful interactions and collaborations.
Mental Health: Maintaining balance and not feeling pressured by user demands.
Key insights include the importance of automation, making the adoption process seamless, and leveraging offline interactions for marketing. The presentation also emphasizes the need for continuous small improvements and building a friendly, inclusive community that contributes to the project's growth.
Vladimir Iglovikov brings his extensive experience as a Kaggle Grandmaster, ex-Staff ML Engineer at Lyft, sharing valuable lessons and practical advice for anyone looking to enhance the adoption of their open-source projects.
Explore more about Albumentations and join the community at:
GitHub: https://github.com/albumentations-team/albumentations
Website: https://albumentations.ai/
LinkedIn: https://www.linkedin.com/company/100504475
Twitter: https://x.com/albumentations
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!SOFTTECHHUB
Â
As the digital landscape continually evolves, operating systems play a critical role in shaping user experiences and productivity. The launch of Nitrux Linux 3.5.0 marks a significant milestone, offering a robust alternative to traditional systems such as Windows 11. This article delves into the essence of Nitrux Linux 3.5.0, exploring its unique features, advantages, and how it stands as a compelling choice for both casual users and tech enthusiasts.
In his public lecture, Christian Timmerer provides insights into the fascinating history of video streaming, starting from its humble beginnings before YouTube to the groundbreaking technologies that now dominate platforms like Netflix and ORF ON. Timmerer also presents provocative contributions of his own that have significantly influenced the industry. He concludes by looking at future challenges and invites the audience to join in a discussion.
In the rapidly evolving landscape of technologies, XML continues to play a vital role in structuring, storing, and transporting data across diverse systems. The recent advancements in artificial intelligence (AI) present new methodologies for enhancing XML development workflows, introducing efficiency, automation, and intelligent capabilities. This presentation will outline the scope and perspective of utilizing AI in XML development. The potential benefits and the possible pitfalls will be highlighted, providing a balanced view of the subject.
We will explore the capabilities of AI in understanding XML markup languages and autonomously creating structured XML content. Additionally, we will examine the capacity of AI to enrich plain text with appropriate XML markup. Practical examples and methodological guidelines will be provided to elucidate how AI can be effectively prompted to interpret and generate accurate XML markup.
Further emphasis will be placed on the role of AI in developing XSLT, or schemas such as XSD and Schematron. We will address the techniques and strategies adopted to create prompts for generating code, explaining code, or refactoring the code, and the results achieved.
The discussion will extend to how AI can be used to transform XML content. In particular, the focus will be on the use of AI XPath extension functions in XSLT, Schematron, Schematron Quick Fixes, or for XML content refactoring.
The presentation aims to deliver a comprehensive overview of AI usage in XML development, providing attendees with the necessary knowledge to make informed decisions. Whether you’re at the early stages of adopting AI or considering integrating it in advanced XML development, this presentation will cover all levels of expertise.
By highlighting the potential advantages and challenges of integrating AI with XML development tools and languages, the presentation seeks to inspire thoughtful conversation around the future of XML development. We’ll not only delve into the technical aspects of AI-powered XML development but also discuss practical implications and possible future directions.
Dr. Sean Tan, Head of Data Science, Changi Airport Group
Discover how Changi Airport Group (CAG) leverages graph technologies and generative AI to revolutionize their search capabilities. This session delves into the unique search needs of CAG’s diverse passengers and customers, showcasing how graph data structures enhance the accuracy and relevance of AI-generated search results, mitigating the risk of “hallucinations” and improving the overall customer journey.
zkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex ProofsAlex Pruden
Â
This paper presents Reef, a system for generating publicly verifiable succinct non-interactive zero-knowledge proofs that a committed document matches or does not match a regular expression. We describe applications such as proving the strength of passwords, the provenance of email despite redactions, the validity of oblivious DNS queries, and the existence of mutations in DNA. Reef supports the Perl Compatible Regular Expression syntax, including wildcards, alternation, ranges, capture groups, Kleene star, negations, and lookarounds. Reef introduces a new type of automata, Skipping Alternating Finite Automata (SAFA), that skips irrelevant parts of a document when producing proofs without undermining soundness, and instantiates SAFA with a lookup argument. Our experimental evaluation confirms that Reef can generate proofs for documents with 32M characters; the proofs are small and cheap to verify (under a second).
Paper: https://eprint.iacr.org/2023/1886
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...James Anderson
Â
Effective Application Security in Software Delivery lifecycle using Deployment Firewall and DBOM
The modern software delivery process (or the CI/CD process) includes many tools, distributed teams, open-source code, and cloud platforms. Constant focus on speed to release software to market, along with the traditional slow and manual security checks has caused gaps in continuous security as an important piece in the software supply chain. Today organizations feel more susceptible to external and internal cyber threats due to the vast attack surface in their applications supply chain and the lack of end-to-end governance and risk management.
The software team must secure its software delivery process to avoid vulnerability and security breaches. This needs to be achieved with existing tool chains and without extensive rework of the delivery processes. This talk will present strategies and techniques for providing visibility into the true risk of the existing vulnerabilities, preventing the introduction of security issues in the software, resolving vulnerabilities in production environments quickly, and capturing the deployment bill of materials (DBOM).
Speakers:
Bob Boule
Robert Boule is a technology enthusiast with PASSION for technology and making things work along with a knack for helping others understand how things work. He comes with around 20 years of solution engineering experience in application security, software continuous delivery, and SaaS platforms. He is known for his dynamic presentations in CI/CD and application security integrated in software delivery lifecycle.
Gopinath Rebala
Gopinath Rebala is the CTO of OpsMx, where he has overall responsibility for the machine learning and data processing architectures for Secure Software Delivery. Gopi also has a strong connection with our customers, leading design and architecture for strategic implementations. Gopi is a frequent speaker and well-known leader in continuous delivery and integrating security into software delivery.
Communications Mining Series - Zero to Hero - Session 1DianaGray10
Â
This session provides introduction to UiPath Communication Mining, importance and platform overview. You will acquire a good understand of the phases in Communication Mining as we go over the platform with you. Topics covered:
• Communication Mining Overview
• Why is it important?
• How can it help today’s business and the benefits
• Phases in Communication Mining
• Demo on Platform overview
• Q/A
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdfPaige Cruz
Â
Monitoring and observability aren’t traditionally found in software curriculums and many of us cobble this knowledge together from whatever vendor or ecosystem we were first introduced to and whatever is a part of your current company’s observability stack.
While the dev and ops silo continues to crumble….many organizations still relegate monitoring & observability as the purview of ops, infra and SRE teams. This is a mistake - achieving a highly observable system requires collaboration up and down the stack.
I, a former op, would like to extend an invitation to all application developers to join the observability party will share these foundational concepts to build on:
UiPath Test Automation using UiPath Test Suite series, part 6DianaGray10
Â
Welcome to UiPath Test Automation using UiPath Test Suite series part 6. In this session, we will cover Test Automation with generative AI and Open AI.
UiPath Test Automation with generative AI and Open AI webinar offers an in-depth exploration of leveraging cutting-edge technologies for test automation within the UiPath platform. Attendees will delve into the integration of generative AI, a test automation solution, with Open AI advanced natural language processing capabilities.
Throughout the session, participants will discover how this synergy empowers testers to automate repetitive tasks, enhance testing accuracy, and expedite the software testing life cycle. Topics covered include the seamless integration process, practical use cases, and the benefits of harnessing AI-driven automation for UiPath testing initiatives. By attending this webinar, testers, and automation professionals can gain valuable insights into harnessing the power of AI to optimize their test automation workflows within the UiPath ecosystem, ultimately driving efficiency and quality in software development processes.
What will you get from this session?
1. Insights into integrating generative AI.
2. Understanding how this integration enhances test automation within the UiPath platform
3. Practical demonstrations
4. Exploration of real-world use cases illustrating the benefits of AI-driven test automation for UiPath
Topics covered:
What is generative AI
Test Automation with generative AI and Open AI.
UiPath integration with generative AI
Speaker:
Deepak Rai, Automation Practice Lead, Boundaryless Group and UiPath MVP
Removing Uninteresting Bytes in Software FuzzingAftab Hussain
Â
Imagine a world where software fuzzing, the process of mutating bytes in test seeds to uncover hidden and erroneous program behaviors, becomes faster and more effective. A lot depends on the initial seeds, which can significantly dictate the trajectory of a fuzzing campaign, particularly in terms of how long it takes to uncover interesting behaviour in your code. We introduce DIAR, a technique designed to speedup fuzzing campaigns by pinpointing and eliminating those uninteresting bytes in the seeds. Picture this: instead of wasting valuable resources on meaningless mutations in large, bloated seeds, DIAR removes the unnecessary bytes, streamlining the entire process.
In this work, we equipped AFL, a popular fuzzer, with DIAR and examined two critical Linux libraries -- Libxml's xmllint, a tool for parsing xml documents, and Binutil's readelf, an essential debugging and security analysis command-line tool used to display detailed information about ELF (Executable and Linkable Format). Our preliminary results show that AFL+DIAR does not only discover new paths more quickly but also achieves higher coverage overall. This work thus showcases how starting with lean and optimized seeds can lead to faster, more comprehensive fuzzing campaigns -- and DIAR helps you find such seeds.
- These are slides of the talk given at IEEE International Conference on Software Testing Verification and Validation Workshop, ICSTW 2022.
2. Agenda
• Sync To Async Code
• Async state machine
• Async logical call stack (chain of continuations)
• Debug
• Parallel Stacks for Tasks and Theads
• Tasks Window
• Threads Window
• Parallel Watch
• Rethrown Exceptions
• Snapshot on Exception (IntelliTrace -> Historical Debugger)
• Async Guidance
• Q&A
3. Start plain and simple
public double GetTotalOderedByCustomer(string customer)
{
double total = 0;
foreach (var order in GetOrdersByCustomer(customer))
{
var details = order.GetOrderDetails();
total += details.Sum(d => d.Quantity * d.UnitPrice);
}
return total;
}
Everythings is frozen and
we are doomed !
…How about adding
some async/await ?
4. Compiler generated code
public async Task<double> GetTotalOderedByCustomerAsync(string customer)
{
double total = 0;
foreach (var order in await GetOrdersByCustomerAsync(customer))
{
var details = await order.GetOrderDetailsAsync();
total += details.Sum(d => d.Quantity * d.UnitPrice);
}
return total;
}
[AsyncStateMachine(typeof(<GetTotalOderedByCustomerAsync>d__0))]
[DebuggerStepThrough]
public Task<double> GetTotalOderedByCustomerAsync(string customer)
{
<GetTotalOderedByCustomerAsync>d__0 stateMachine = new
<GetTotalOderedByCustomerAsync>d__0();
stateMachine.<>t__builder = AsyncTaskMethodBuilder<double>.Create();
stateMachine.<>4__this = this;
stateMachine.customer = customer;
stateMachine.<>1__state = -1;
stateMachine.<>t__builder.Start(ref stateMachine);
return stateMachine.<>t__builder.Task;
}
SharpLab.io
5. Compiler generated code
public async Task<double>
GetTotalOderedByCustomerAsync(string customer)
{
double total = 0;
foreach (var order in await
GetOrdersByCustomerAsync(customer))
{
var details = await order.GetOrderDetailsAsync();
total += details.Sum(d => d.Quantity *
d.UnitPrice);
}
return total;
}
[CompilerGenerated]
private sealed class <GetTotalOderedByCustomerAsync>d__0 : IAsyncStateMachine
{
public int <>1__state;
public AsyncTaskMethodBuilder<double> <>t__builder;
// local variables !
public string customer;
public DataService <>4__this;
private double <total>5__1;
...
// awaiters !
private TaskAwaiter<IEnumerable<Order>> <>u__1;
private TaskAwaiter<IEnumerable<OrderDetail>> <>u__2;
private void MoveNext()
{
int num = <>1__state;
double result;
try
{
TaskAwaiter<IEnumerable<Order>> awaiter;
if (num != 0)
{
if (num == 1)
{
goto IL_00c4;
}
<total>5__1 = 0.0;
awaiter = <>4__this.GetOrdersByCustomerAsync(customer).GetAwaiter();
SharpLab.io
10. So how do we debug this ?
Async logical call stack
The first thing used while debugging are «call stacks»
Call stack show caller -> callee relation !
We also need call stack fro async code – such as «async call stacks»
11. Async vs sync stacks
SYNC stacks ASYNC stacks
Code is currently running on a thread Code may not be running anywhere or
scheduled to run in the future
Hence – Physical stacks Virtual or logical stacks. Not tied to a single
(or any) thread.
Locals are allocated on stack memory Local are stashed in “state machines” (internal
compiler generated helper structures)
12. Async call stacks
Task #1
GetOrderByCustomerAsync()
m_continuation
public async Task<double> GetTotalOderedByCustomerAsync(string customer)
{
double total = 0;
foreach (var order in await GetOrdersByCustomerAsync(customer))
{
var details = await order.GetOrderDetailsAsync();
total += details.Sum(d => d.Quantity * d.UnitPrice);
}
return total;
}
Task #2
GetOrderDetailsAsync()
m_continuation
Here the await keyword adds the next line of GetTotalOrderedByCutomerAsync
as a continuation to GetOrdersByCustomerAsync.
The Task of GetOderDetailsAsync store a reference to the next line of
GetTotalOrderedByCutomerAsync to invoke when done.
13. Async call stacks
Task #1
GetOrderByCustomerAsync()
m_continuation
Task #2
GetOrderDetailsAsync()
m_continuation
The debugger walks through this chain of references – to get a chain of
continuations
Async Logical Stacks
GetOrderDetailsAsync
GetOrderByCustomerAsync
The chian of continuations is what we call async call stack
14. Async call stacks
Task #1
GetOrderByCustomerAsync()
m_continuation
Task #2
GetOrderDetailsAsync()
m_continuation
Async stack are a continuation stack
This may be quite different from the stack or context of where the task
was created – that is, the creation stack
Task #N
...
m_continuation
15. Creation Stack vs Continuation Stack
Note that TakeABreak is not part of the async call stack
Async Task
> Task.Delay(…)
DoSomething(…)
public Task TakeABreak()
{
return Task.Delay(1000);
}
public async Task DoSomething()
{
foreach (var order in orders)
{
Task pause = TakeABreak();
details = await order.GetOrderDetails();
await pause;
}
}
??? TakeABreak(…) ???
16. Creation Stack vs Continuation Stack
Sync call stack are also really just continuation stack: the creation (call) and
continuation are the same
In async, control goes to whoever awaits (or waits) the current async code,
which may be different from the scope or method in which it was called.
Keep that in mind while async debugging – especially while using
TaskCompletitionSource<T> [used for APM (Asynchronous Programming Model)
or EAP (Event-Based Asynchronous Pattern)].
17. EAP sample
public static class StoryboardHelper
{
public static Task RunAsync(this Storyboard storyboard)
{
var tcs = new TaskCompletionSource<object>();
EventHandler<object> completion = null;
completion = (sender, args) =>
{
storyboard.Completed -= completion;
tcs.SetResult(null);
};
storyboard.Completed += completion;
storyboard.Begin();
return tcs.Task;
}
}
…
await myStoryboard.RunAsync();
22. Async Code Tips
• Async void
• Prefer Task.FromResult over Task.Run for pre-computed or trivially computed data
• Avoid using Task.Run for long running work that blocks the thread
• Avoid using Task.Result and Task.Wait
• Prefer await over ContinueWith
• Always create TaskCompletionSource<T> with TaskCreationOptions.RunContinuationsAsynchronously
• Always dispose CancellationTokenSource(s) used for timeouts
• Always flow CancellationToken(s) to APIs that take a CancellationToken
• Cancelling uncancellable operations
• Always call FlushAsync on StreamWriter(s) or Stream(s) before calling Dispose
• Prefer async/await over directly returning Task
• ConfigureAwait
The first debugging step is writing good code !
AsyncGuidance
23. Q&A
.NET
your platform for building anything
Mirco Vanini
Microsoft® MVP Windows Development
myContactInfo:
{
”e-mail”:“mirco.vanini@proxsoft.it”,
“web”: “www.proxsoft.it”,
“twitter”: “@MircoVanini”
}