Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Delphi High Performance

You're reading from   Delphi High Performance Build fast Delphi applications using concurrency, parallel programming and memory management

Arrow left icon
Product type Paperback
Published in Feb 2018
Publisher Packt
ISBN-13 9781788625456
Length 336 pages
Edition 1st Edition
Languages
Arrow right icon
Author (1):
Arrow left icon
Primož Gabrijelčič Primož Gabrijelčič
Author Profile Icon Primož Gabrijelčič
Primož Gabrijelčič
Arrow right icon
View More author details
Toc

Table of Contents (11) Chapters Close

Preface 1. About Performance 2. Fixing the Algorithm FREE CHAPTER 3. Fine-Tuning the Code 4. Memory Management 5. Getting Started with the Parallel World 6. Working with Parallel Tools 7. Exploring Parallel Practices 8. Using External Libraries 9. Best Practices 10. Other Books You May Enjoy

Async/Await


Tasks are powerful but clumsy. The real power of modern multithreading libraries comes not from them, but from specialized code designed to solve specific usage patterns (pattern or a parallel pattern for short). Although I intend to cover all of the patterns implemented in the Parallel Programming Library, I'll start with a pattern you won't find there.

The Async/Await pattern comes from .NET. It allows you to start a background task (async) and execute some code in the main thread after the task completes its work (await). In Delphi, we cannot repeat the incredible usefulness of the .NET syntax, as it requires support from the compiler, but we can approximate it with something that is useful enough. Such an implementation can be found in my OmniThreadLibrary. For the purpose of this book, I have re-implemented it in the unit DHPThreading, which you can freely use in your code.

The AsyncAwait demo shows when this pattern can be useful and how to use it. The Long task button calls...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at AU $24.99/month. Cancel anytime