Skip to content

Webinar Replay: Introducing RAD Studio, Delphi and C++Builder 10.1 Berlin

Webinar Replay: Introducing RAD Studio, Delphi and C++Builder 10.1 Berlin
Thursday, April 21, 2016

Embarcadero YouTube Channel at: https://www.youtube.com/watch?v=1CHPXbUeSJ8

  • Launch Webinar Starts at: 00:00:00
  • Q&A Starts at: 01:10:32
  • Webinar Replay Ends at: 02:09:42

 

RAD Studio, Delphi and C++Builder 10.1 Berlin provide you with the fastest way to develop applications for Windows 10, Cross-Platform, Enterprise Architectures, Cloud Services and the Internet of Things.

You’ll see how 10.1 Berlin provides:

  • A completely new installation experience
  • Enhanced quality, performance, and stability (QPS)
  • Enhanced developer productivity including the new floating VCL form designer
  • Improvements in native toolchain, compiler and platform components
  • New Internet of Things architecture with dozens of pre-built ThingConnect IoT components and ThingPoint Edge Services
  • New FireMonkey components and features including on-device preview
  • Enterprise strong app development for database, multi-tier and cloud technologies 
  • And a whole lot more!

RAD Studio Product Managers Marco Cantu and Sarina Dupont cover the overall product directions and provide technical details on the new product features. See how RAD Studio works with and will continue extending its support for Windows 10, multi-device development, enterprise development and the Internet of Things. The webinar also includes technical Delphi and C++ demos and a Q&A session.

The RAD Studio 10.1 Berlin Launch Webinar Powerpoint Slide Deck is available on CodeCentral at http://cc.embarcadero.com/item/30527

RAD Studio product page: https://www.embarcadero.com/products/rad-studio

Delphi product page: https://www.embarcadero.com/products/delphi

C++Builder product page: https://www.embarcadero.com/products/cbuilder

[DownloadButton Product='RAD' Caption='RAD Studio 10.1 Berlin Free Trial Download']

[BuyButton Product='RAD' Caption='Buy RAD Studio 10.1 Berlin']

 

 

 

Fire up your business and users with RAD Studio 10.1 Berlin’s “Enterprise Strong” Desktop, Mobile, Database, Server, Cloud and IoT Solutions

Webinar: Fire up your business and users with RAD Studio 10.1 Berlin’s “Enterprise Strong” Desktop, Mobile, Database, Server, Cloud and IoT Solutions

Date/Time(s)/Registration:

Thursday, May 5, 2016

6am, 11am and 5pm PDT

Please register for the date and time that works best for you:

https://attendee.gotowebinar.com/rt/8462342139092883458

Webinar Agenda

This technical webinar goes deep into RAD Studio 10.1 Berlin’s new support for the latest enterprise database technologies, REST-based services, cloud services and the Internet of Things. Source code demos will show you how to access the latest enterprise SQL databases and MongoDB NoSQL database. You will see source code demos that will show you how to access the latest major enterprise SQL databases and MongoDB NoSQL database. You’ll learn how to write your own applications that integrate data from multiple IoT devices into your desktop, server and cloud applications. You’ll see how to rapidly create REST based endpoints that can be called from Delphi, C++ and other programming languages.

During this webinar you’ll learn how to develop cutting edge desktop, mobile, server and cloud based applications using:

  • FireDAC’s optimized database access for all the latest major enterprise RDBMS including Oracle, Microsoft SQL Server, and MongoDB
  • ThingConnect IoT component support a wide array of devices including health monitoring, home automation, fitness tracking, industrial and security sensors. ThingConnect data can be used to in local and distributed device monitoring solutions.
  • RAD Server (built on EMS core technology) support for cross domain API calls, creation of ThingPoint Edge Services, Swagger open API with YAML and JSON representations for API testing and documentation generation, execution on IIS and Apache web production environment servers.
  • Integrating cloud based development into your enterprise and IoT solutions using the latest Amazon and Azure cloud API support for storage, messaging and services.
  • And More…

Join the Embarcadero Evangelism team for this online webinar loaded with technical demonstrations. The team will also be on hand to answer your questions.

RAD Studio 10.1 Berlin Feature Installer "How To" video

I have created a short "How To" video that demonstrates the new Feature Installer in RAD Studio 10.1 Berlin. We still provide an ISO image that uses a traditional Windows installation process called the "Offline Installer". We also provide an online incremental installer that gets you started fast. We call this installer the "Feature Installer". The Feature Installer is an installation wizard that lets you select an initial set of RAD Studio features to install, such as support for specific combinations of programming languages and target platforms, language support, or help resources. During the installation process, the Installer starts the Feature Installer automatically.During the installation process, you must have a working internet connection to download content required to install the selected features. After you install RAD Studio, you can install additional features or remove installed features using the Feature Manager. You’ll find it in the IDE’s Tools | Manage Platforms menu item.

You can watch this short video (4 minutes and 50 seconds) on the Embarcadero YouTube channel at https://www.youtube.com/watch?v=4zt1TnYttds

You can read the RAD Studio 10.1 Berlin press release announcement at http://community.embarcadero.com/article/news/16226-embarcadero-announces-release-updates-for-rad-studio-c-builder-and-delphi

 

RAD Studio 10.1 Berlin, REST/JSON and using a fun site: Name2Gender.com

I was thinking about how I would do a gender based analysis of our customer database without surveying our customers. The Embarcadero Community profile does not ask whether you are male or female. At the recent Evans Data Developer Relations Conference, there was a presentation about the number of developers in the world (currently around 19 million going up to 25 million in 2020). Evans Data puts the global number of female developers near 20%. In a November 2015 report, IDC said that "24% of North American developers are female". I am always looking around for new REST based sites to test our REST Client Library Components. Wondering what our Delphi, C++Builder and RAD Studio developer gender profile looks like, I started to see how I might analyze the first names of our customers. I looked at several sources of first name analysis including the United States Social Security name list. As part of my search, I found a site that has a REST/JSON API to search for the likely gender by first name. The site is Name2Gender.com.

Using the RAD Studio 10.1 Berlin REST Debugger and REST Client Library components, I quickly tested Name2Gender’s REST API and built Delphi and C++ multi-device projects that run on Windows, OS X, iOS and Android.  Here are some screen shots and the source code. You can find a zip file with the two projects on CodeCentral at http://cc.embarcadero.com/item/30524.

The Application UI at Design and Runtime

The main application form is very simple. The form contains the following components: TButton, TEdit, TStringGrid, TMemo, TCircle (2), TLabel (5) TFDMemTable, TRESTClient, TRESTRequest, TRESTResponse, TRESTResponseDataSetAdapter, TBindSourceDB and TBindingsList. I used the REST Debugger’s "CopyToClipboard" to add the REST Client Library components to my application with the settings from my test of the Name2Gender API.

 

The following are several screen grabs showing my app in action on Windows (I also have created form views for OS X, iOS and Android). I tested likely male and female names. I also tried less likely names and one case where I did not enter a name. If you look at the source code, you’ll see where I use the returned "accuracy" percentage to set the colors for the two TCircle indicators.

 

 

 

 

 

The Project Group in the Project Manager

The project group contains C++Builder and Delphi Multi-Device FireMonkey projects. For each form, I created Windows, OS X, iOS and Android form views. You will find the different FMX form inheritance files (for Windows, OS X, iPhone 4.7 inch, and Android 4 inch form factors) in the source code zip file on CodeCentral.

 

The C++ source code

Here is the C++ source code for the button OnClick handler. I also set the starting color for each TCircle in the OnFormCreate event handler. Notice, that I arbitrarily used the accuracy result to set the second TCircle to Green, Yellow or Red.

void __fastcall TForm3::Button1Click(TObject *Sender)
{
  Memo1->Lines->Clear();
  StatusCircle->Fill->Color = TAlphaColors::Lightgray;
  AccuracyCircle->Fill->Color = TAlphaColors::Lightgray;
  RESTRequest1->AddParameter("Name",UpperCase(Edit1->Text));
  RESTRequest1->Execute();
  RESTStatusLabel->Text = IntToStr(RESTResponse1->StatusCode)+"/"+RESTResponse1->StatusText;
  Memo1->Lines->Add(RESTResponse1->JSONText);
  if (RESTResponse1->StatusCode != 200) {
StatusCircle->Fill->Color = TAlphaColors::Red;
switch (RESTResponse1->StatusCode) {
  case 403:
RESTRequestErrorLabel->Text = "Forbidden access to Private section";
break;
  case 460:
RESTRequestErrorLabel->Text = "User already registered";
break;
  case 461:
RESTRequestErrorLabel->Text = "Not Found by required parameters";
break;
  case 462:
RESTRequestErrorLabel->Text = "Invalid user session id";
break;
  case 463:
RESTRequestErrorLabel->Text = "Name cannot be empty";
break;
  case 464:
RESTRequestErrorLabel->Text = "Ip and Key cannot be null at the same time";
break;
  case 465:
RESTRequestErrorLabel->Text = "Current available calls for ApiKey is 0";
break;
  case 466:
RESTRequestErrorLabel->Text = "Ip request day limit";
break;
  case 500:
RESTRequestErrorLabel->Text = "Internal server exception";
break;
default:
  RESTRequestErrorLabel->Text = "Unknown Error";
};
  }
  else {
StatusCircle->Fill->Color = TAlphaColors::Green;
RESTRequestErrorLabel->Text = "";
  };
  if (RESTResponse1->StatusCode == 200) {
AccuracyResultLabel->Text = FDMemTable1accuracy->AsString;
if (FDMemTable1accuracy->AsFloat >= 90.0) {
  AccuracyCircle->Fill->Color = TAlphaColors::Green;
}
else if (FDMemTable1accuracy->AsFloat >= 70.0) {
  AccuracyCircle->Fill->Color = TAlphaColors::Yellow;
}
else {
  AccuracyCircle->Fill->Color = TAlphaColors::Red;
}
  }
  else {
AccuracyResultLabel->Text = "No Result";
AccuracyCircle->Fill->Color = TAlphaColors::Red;
  }
}
//---------------------------------------------------------------------------
void __fastcall TForm3::FormCreate(TObject *Sender)
{
  StatusCircle->Fill->Color = TAlphaColors::Lightgray;
  AccuracyCircle->Fill->Color = TAlphaColors::Lightgray;
}

 

The Delphi source code

Here is the Delphi source code for the button OnClick handler. I also set the starting color for each TCircle in the OnFormCreate event handler. Notice, that I arbitrarily used the accuracy result to set the second TCircle to Green, Yellow or Red.

procedure TForm1.Button1Click(Sender: TObject);
begin
  Memo1.Lines.Clear;
  StatusCircle.Fill.Color := TAlphaColors.Lightgray;
  AccuracyCircle.Fill.Color := TAlphaColors.Lightgray;
  RESTRequest1.Params[0].Value := UpperCase(Edit1.Text);
  RESTRequest1.Execute();
  RESTStatusLabel.Text := IntToStr(RESTResponse1.StatusCode)+'/'+RESTResponse1.StatusText;
  Memo1.Lines.Add(RESTResponse1.JSONText);
  if RESTResponse1.StatusCode <> 200 then begin
    StatusCircle.Fill.Color := TAlphaColors.Red;
    case RESTResponse1.StatusCode of
      403: RESTRequestErrorLabel.Text := 'Forbidden access to Private section';
      460: RESTRequestErrorLabel.Text := 'User already registered';
      461: RESTRequestErrorLabel.Text := 'Not Found by required parameters';
      462: RESTRequestErrorLabel.Text := 'Invalid user session id';
      463: RESTRequestErrorLabel.Text := 'Name cannot be empty';
      464: RESTRequestErrorLabel.Text := 'Ip and Key cannot be null at the same time';
      465: RESTRequestErrorLabel.Text := 'Current available calls for ApiKey is 0';
      466: RESTRequestErrorLabel.Text := 'Ip request day limit';
      500: RESTRequestErrorLabel.Text := 'Internal server exception';
    else
      RESTRequestErrorLabel.Text := 'Unknown Error'
    end;
  end
  else begin
    StatusCircle.Fill.Color := TAlphaColors.Green;
    RESTRequestErrorLabel.Text := '';
  end;
  if RESTResponse1.StatusCode = 200 then begin
    AccuracyResultLabel.Text := FDMemTable1accuracy.AsString;
    if FDMemTable1accuracy.AsFloat >= 90.0 then
      AccuracyCircle.Fill.Color := TAlphaColors.Green
    else if FDMemTable1accuracy.AsFloat >= 70.0 then
      AccuracyCircle.Fill.Color := TAlphaColors.Yellow
    else
      AccuracyCircle.Fill.Color := TAlphaColors.Red;
  end
  else begin
    AccuracyResultLabel.Text := 'No Result';
    AccuracyCircle.Fill.Color := TAlphaColors.Red;
  end;
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
  StatusCircle.Fill.Color := TAlphaColors.Lightgray;
  AccuracyCircle.Fill.Color := TAlphaColors.Lightgray;
end;

 

Project Group Source Code on CodeCentral

You can find the complete source code to both projects in CodeCentral at http://cc.embarcadero.com/item/30524

A Final Note

I have not done the analysis of our Developer Network members, but I will use the REST component settings from these projects, to read through our customer database and see what I find. The Name2Gender site has several levels of pricing depending on how many REST calls you make.

 

[DownloadButton Product='RAD' Caption='RAD Studio 10.1 Berlin - Try for Free']

[BuyButton Product='RAD' Caption='RAD Studio 10.1 Berlin - Now Available for Purchase']

Introducing RAD Studio, Delphi and C++Builder 10.1 Berlin - Webinars on April 21 at 6am, 11am and 5pm Pacific Time

Embarcadero

 

 RAD Studio 10.1 Berlin

RAD STUDIO WEBINAR 21 & 22 APRIL

 

Introducing RAD Studio, Delphi and C++Builder 10.1 Berlin

RAD Studio, Delphi and C++Builder 10.1 Berlin provide you with the fastest way to develop applications for Windows 10, Cross-Platform, Enterprise Architectures, Cloud Services and the Internet of Things.

During this launch webinar you’ll see how 10.1 Berlin provides:

  • A completely new installation experience
  • Enhanced quality, performance, and stability (QPS)
  • Enhanced developer productivity including the new floating VCL form designer
  • Improvements in native toolchain, compiler and platform components
  • New Internet of Things architecture with dozens of pre-built ThingConnect IoT components and ThingPoint Edge Services
  • New FireMonkey components and features including on-device preview
  • Enterprise strong app development for database, multi-tier and cloud technologies
  • And a whole lot more!

RAD Studio Product Managers Marco Cantu and Sarina Dupont will cover the overall product directions and provide technical details on the new product features. See how RAD Studio works with and will continue extending its support for Windows 10, multi-device development, enterprise development and the Internet of Things. The webinar will also include technical Delphi and C++ demos and a Q&A session.

There is one link for the 3 global webinars –
please choose the time that fits your schedule.

21 April 2016
06:00 San Francisco
09:00 New York
14:00 London
15:00 Berlin

21 April 2016
11:00 San Francisco
14:00 New York
19:00 London
20:00 Berlin

21 April 2016
17:00 San Francisco
22 April 2016
10:00 Tokyo
12:00 Sydney

 
 

PRODUCTS · SOLUTIONS · SUPPORT · COMMUNITY · STORE · CONTACT

 

Facebook Twitter Google Plus LinkedIn Youtube
 

Visual Arduino programming for kids and professionals using Visuino by Mitov Software - powered by Embarcadero Delphi

I am often by parents how they can get their kids interested in technology and programming in a fun and educational way. When I was a kid growing up I played with erector sets, built my own crystal radio, used my Edmund Scientific kit to create microscopes and telescopes. I used to show my Lego Mindstorms kit, my IMSAI 8080 computer that I build from a kit in 1974, my Arduino boards and now my RaspberryPi 2 device. There are many other computer programming education systems including Alice, Scratch, Squeak and Logo. For high school students you can set them in front of an integrated environment and let them use Delphi, C++, Java, Python, Javascript and Ruby to learn how to create applications. For younger kids, I think one of the best ways to learn about technology and programming is to use Arduino and RaspberryPi type boards connected to their PCs and Macs. The combination of the computer kids already use and these low cost and fun devices allows them to explore and integrate with world around them. There is a new visual programming environment for Arduino based fun called Visuino by Mitov Software.

Visuino is an Arduino IDE built using Embarcadero Delphi that allows you to build Arduino programs on your PC and compile the programs for Arduino and wide range of connected devices, sensors and circuits. On the Visuino page it states "A visual programming environment allowing you to program your Arduino boards. Although it currently supports the official Arduino boards, it is not restricted to their support alone and requests to support new hardware are welcome. If you are a hardware developer and don’t have much time to become an expert in software development then you can let Visuino become your personal software expert. If you’ve been exposed to the existing offering from Arduino you may be overwhelmed by the complexity of designing code to run your hardware components."

I have been working with some of the beta releases and having fun with LEDs, motors, gears and sensors. Sure, hardware, programmers, makers and tinkers can use Visuino to the max. Kids can also collaborate with their parents and other kids to learn real world technical and programming skills using Visuino.

You can download a trial at https://www.visuino.com/. Also, read the FAQ on the Visuino site. You can follow the discussions about Visuino on the Google+ group at https://plus.google.com/communities/116125623808250792822

Disclaimer: Mitov Software is an Embarcadero Technology Partner. While I was involved in the beta test of Visuino and it is built using Embarcadero Delphi, I have no direct involvement in Visuino development or marketing. I absolutely think Visuino is way cool, a great learning tool for kids and a testament to what you can build using Embarcadero development tools.

 

Webinar: Thursday, April 21 (6am, 11am, 5pm PDT) - The new highlights of RAD Studio, C ++ Builder and Delphi!

This webinar will offer on overview of the latest release of RAD Studio, Delphi and C ++ Builder. RAD Studio Product Managers Marco Cantu and Sarina Dupont will cover the overall product directions and provide details about today’s product and hints about its future. See how RAD Studio works with and will continue extending its support for Windows 10, multi-device development, and the Internet of Things. Embarcadero presenters will discuss among other things the following topics: A new installation tool with GetIt technology and the choice of what you want to install Extended support for Bluetooth LE on Windows 10 and a framework for IoT components FireUI App Preview - Preview your forms on any target device (desktop or mobile) … and much more!

There is one link for the 3 global webinars –
you can choose the time that fits your schedule.

 

21 April 2016
06:00 San Francisco
09:00 New York
14:00 London
15:00 Berlin

 

21 April 2016
11:00 San Francisco
14:00 New York
19:00 London
20:00 Berlin

 

21 April 2016
17:00 San Francisco
22 April 2016 
10:00 Tokyo
12:00 Sydney

 

 

Please register for the date and time that works best for you. Register now!

    https://attendee.gotowebinar.com/rt/8114586402052971010

After registering, you will receive a confirmation email containing information about joining the webinar.

 

David I’s (@davidi99) Tweets of the Week - Apr 3-9, 2016

Here are my posted Tweets for the week of Sunday, April 3, 2016 to Saturday, April 9, 2016. Embarcadero specific posts are in bold.

 

Sunday, April 3, 2016

 

Monday, April 4, 2016

 

Tuesday, April 5, 2016

 

Wednesday, April 6, 2016

 

Thursday, April 7, 2016

 

Friday, April 8, 2016

 

Saturday, April 9, 2016

You can follow me on Twitter - https://twitter.com/davidi99

Community Forums Nugget – How to program iOS application preferences for the iPhone Settings > General section

On the Community forums, David J recently asked: "Most iOS apps have the preferences set into the Settings > General section instead of embedded in the app. Any example on how to split that and take it out of the app and place it in the correct place on iOS? Thanks for any light"

I replied: David Clegg wrote an article that shows you how to do this for Delphi (would work the same for C++Builder). you can find the article at http://community.embarcadero.com/article/technical-articles/162-programming/1852-persisting-settings-in-delphi-ios-applications. Cleggy notes: "In Cocoa apps created in Xcode, the way to specify settings associated with your app is to include a settings.bundle when compiling your app. For Delphi apps, the approach is no different. You can leverage Xcode to create the settings bundle, which you can refer to when specifying the resources to bundle in your compiled Delphi app." Cleggy goes on to show you how to create a settings.app bundle to include in your Delphi or C++Builder iOS application. He also includes code for reading and writing the settings.

 

Using C++11 Lambda functions with the C++Builder Parallel Programming Library

With the introduction of the Parallel Programming Library (PPL) and Embarcadero C++Builder support for C++11 lambda functions on the Win32, Win64, iOS and Android platforms, you can now use the two in combination in your applications. Below you will find C++Builder example source code that uses lambda functions with the Parallel For, Tasks and Futures. If you use C++11 features (including lamda functions) in your applications that target Win32, make sure you turn off (set to False) the "Use classic Borland compiler" in the Projects | Options | C++ Compiler dialog.

Parallel For

The Parallel Programming Library (PPL) includes a Parallel for loop method. The TParallel.For accepts anonymous methods in Delphi whereas in C++ you create an Iterator event function or C++11 lambda and pass that as part of the TParallel::For loop call. In this example, I show you the two ways to use an iterator function in the Parallel::For method: using an event style iterator and using a C++11 lambda. I’ve commented out the use of the iterator function in favor of using the C++11 lambda function. Note: the variable Tot is defined in the public section of the form class. 

#include <System.Threading.hpp>
#include <System.Diagnostics.hpp>
#include <System.SysUtils.hpp>

...

// test if a number is a prime number
bool IsPrime(int N) {
  bool aPrime = true;
  for (int Test = 2;Test<=N-1;Test++) {
if (N % Test == 0) {
  aPrime = false;
  break; //jump out of the for loop
}
  }
  return aPrime;
}

// Parallel For Iterator Event Proc
void __fastcall TForm2::MyIteratorEvent(TObject* Sender, int AIndex)
{
if (IsPrime(AIndex)) {
TInterlocked::Increment(Tot);
};
}

// Button event handler that finds prime numbers using Parallel::For
void __fastcall TForm2::Button2Click(TObject *Sender)
{
  // counts the prime numbers below a given value
  int Max = 50000; // 50K
  Tot = 0;
  System::Diagnostics::TStopwatch sw = System::Diagnostics::TStopwatch::Create();
  sw.Start();
  // TParallel::For(NULL,1,Max,MyIteratorEvent);  // using an iterator "event" method
  // using C++11 Lambda for the parallel for (Note: for Win32 turn off option "Use Classic Compiler"
  TParallel::For(NULL,1,Max,
  System::Sysutils::_di_TProc__1<int>(
  // [this] (int AIndex) {
  [&] (int AIndex) {
  if (IsPrime(AIndex)) {
  TInterlocked::Increment(Tot);
  };
  }
  )
  );
  sw.Stop();
  Memo1->Lines->Add (
String().sprintf(L"Parallel For loop. Time (in milliseconds): %lld, Primes found: %d",
sw.ElapsedMilliseconds,Tot)
  );
}

// Button event handler that uses sequential for look to find prime numbers
void __fastcall TForm2::Button1Click(TObject *Sender)
{
  // counts the prime numbers below a given value
  int Max = 50000; // 50K
  Tot = 0;
  System::Diagnostics::TStopwatch sw = System::Diagnostics::TStopwatch::Create();
  sw.Start();
  for (int I = 1;I<=Max;I++) {
if (IsPrime(I)) {
  Tot++;
  // Application.ProcessMessages;
}
  }
  sw.Stop();
  Memo1->Lines->Add (
String().sprintf(L"Sequential For loop. Time (in milliseconds): %lld, Primes found: %d",
sw.ElapsedMilliseconds,Tot)
  );
}

 

Parallel Task

The Parallel Programming Library (PPL) provides a TTask class to run one task or multiple tasks in parallel. A Task is a unit of work you need to get done. The PPL does the association between the task and the thread that performs the task so you can run several tasks in parallel without having to create your own custom threads and managing them. This example creates two parallel tasks that use C++11 lambda functions. Inside of the button event handler, the Parallel Task WaitForAny and WaitForAll methods are used.

#include <System.Threading.hpp>

...

void __fastcall TForm1::Button1Click(TObject *Sender)
{
   int counter = 0;
   _di_ITask tasks[2];

   tasks[0] = TTask::Create([&] () {
   Sleep(3000);
   TInterlocked::Add(counter,1);

   });

   tasks[1] = TTask::Create([&] () {
   Sleep(5000);
   TInterlocked::Add(counter,1);

   });

   for(auto task: tasks) {
   task->Start();
   }

   Label1->Caption = "All Tasks Started";
   Label1->Update();

   TTask::WaitForAny(tasks,(sizeof(tasks)/sizeof(tasks[0])-1));
   Label1->Caption = "At least one task is done! "+IntToStr(counter);
   Label1->Update();

   TTask::WaitForAll(tasks,(sizeof(tasks)/sizeof(tasks[0])-1));
   Label1->Caption = "All tasks are done! "+IntToStr(counter);
   Label1->Update();
}

 

Parallel Future

This sample shows you how to use C++11 lambda functions with the Parallel Future feature in the Parallel Programming Library. Parallel Future uses TTask::Future to launch a function that returns a specific type. TTask::Future<T>, where the type parameter, T, represents the return type. Using a future allows you to calculate something or run some query and at the same time you can do other tasks, getting the value when you want via future’s value. If the value is not completed yet, the Parallel Programming Library blocks the current code waiting for this value to be calculated. This allows you to prioritize code blocks to run in the order you want, but still ensure you get the value at the point you need it.

#include <system.threading.hpp>

...

void __fastcall TForm1::Button1Click(TObject *Sender)
{
auto future = TTask::Future<int>([&] () -> int {
// very long computation can go here
Sleep(2000);
return 42;
});
// do other things while the future has not been given a value
Sleep(1000);
// the thread will block until the future value is computed/set
int computedValue = future->Value;
ShowMessage("Future has a value: "+IntToStr(computedValue));

}

 

Links to Additional Resources

 

Source Code on Code Central

You can download the source code examples (tested using C++Builder 10 Seattle) for all three projects using the CodeCentral link - "Using C++11 Lambda functions with the C++Builder PPL" - http://cc.embarcadero.com/item/30508.

 

Bad Behavior has blocked 3884 access attempts in the last 7 days.

Close