Get access to over 100 FireMonkey cross platform samples for Android, IOS, OSX, Windows, and Linux!

AndroidAppmethodCode SnippetDelphiFiremonkeyIOSOSXWindows

How To Utilize Asynchonous Futures In Delphi XE7 Firemonkey On Android And IOS

| Delphi 11 10 XE8 XE7 XE Seattle Berlin Tokyo Rio Firemonkey Delphi Android Delphi IOS

Delphi XE7 Firemonkey Asynchronous Futures | Delphi 11 10 XE8 XE7 XE Seattle Berlin Tokyo Rio Firemonkey Delphi Android Delphi IOSDeveloper Stephen Bell from Embarcadero has a blog post up which explains how the new TTask IFuture functionality works in Delphi XE7 Firemonkey. Futures have been made available in the parallel programming library and work on Android, IOS, Windows, and Mac OSX. A future is sort of an asynchronous function that returns a result sometime later but if asked for it will return it now. So you can setup your TTask.Future to return a string or an integer for example and then continue running other code. When you go to access that string or integer variable later it will check to see if the TTask.Future has already completed (returned the data and populated the variable). If it has not returned the data or completed yet then it will synchronously wait for that asynchronous function to complete before moving on. Here is some sample code from the blog post demonstrating a Future:
var
OneValue: IFuture <Integer>;
begin
OneValue := TTask.Future<Integer>(function: Integer
begin
Result := ComputeSomething;
Sleep(1000); // delay to show status
end);

Head over and check out the full blog post and code snippets for using Futures in Delphi XE7 Firemonkey on Android, IOS, OSX, and Windows.

Have Delphi Firemonkey questions? Ask and get answers on StackOverflow.

Related posts
DelphiDemoFiremonkeyLinuxOSXShowcaseWindows

AutoBlogAI: FireMonkey Client To Leverage LLMs And Generative AI For Blogging

DelphiFiremonkeyShowcaseUtilityWindows

Unleashing Creativity With Song Writer AI: A Deep Dive

DelphiFiremonkeyShowcaseWindows

How To Build Stable Diffusion Text To Image Prompts

AndroidC++BuilderDelphiFiremonkeyIOSOSXWindows

FireMonkey 10.4.2 Features Updated iOS 14, Android 11, And macOS 11 Support Plus Hundreds Of Fixes

Sign up for our Newsletter and
stay informed

Leave a Reply