Posts Tagged ‘Embarcadero’

Updating the UI from a Task

While we’re talking things Parallel, the other part of the same demo from last post showed spawning a single task that slept for awhile and then called ShowMessage.

procedure TFormThreading.Button1Click(Sender: TObject);
var
  aTask: ITask;
  begin
    // not a thread safe snippet
    aTask := TTask.Create(procedure
                          begin
                            sleep(3000); 
                            ShowMessage('Hello');
                          end);
    aTask.Start;
 end;

Note the comment. Read On…

“But what happens if…” : The Joy of Race Conditions

In my last post, I was trying to highlight the fact that just because you have done a WaitForAny and one of your Tasks has ended, the others don’t just all magically stop somehow. It’s good form for your Task to be checking if it has been Cancelled, and to quit as soon as possible, certainly before making any changes outside the context of the Task.

However, as I mentioned at the end of that post, we’re still not done. There is a window of time, albeit a small one, where things could go wrong, and in this post I want to explore what the problem is and how to resolve it. Read On…

WTF is a Future?

Of the abstractions introduced in the Parallel Programming Library, the IFuture<T> seems to be the one that many people have difficulty understanding.

Both TTask and TParallel.For seem reasonably easy to understand conceptually, even if you don’t understand all the details. TTask is about some code you want to run in parallel to the main thread. TParallel.For is about performing some actions on the items in a collection in parallel. In both cases you are focussed on the actions you want to perform. Read On…

XE7 VCL Events in Asia Pacific During November

We have a bunch of RAD Studio XE7 events coming up in APAC over the next month or so. They are free, half day sessions focussed on modernising existing VCL applications, where you’ll learn topics such as:

  • New VCL components, such as TaskBar and JumpList and how to easily add them to existing apps
  • Using the new Parallel Programming Library to improve the performance of your application
  • Migrating a BDE application to FireDAC
  • Extending an existing VCL application with a mobile companion app using App Tethering

 

The current list of cities, along with links to more details are:

Read On…

ShowModal on Android

FireMonkey does a lot of work to allow you to write one set of code that compiles and runs on different platforms.

Not only that, it also does a lot of work to make many of the coding patterns that some of you are used to from the VCL on Windows, work unchanged on other platforms.

That’s great, but in some cases, re-using old patterns is not desirable. ShowModal is a case in point. Read On…

“No Code” Calculated Fields in RAD Studio and AppMethod

In Perth last week I was showing the new FieldOptions property on datasets. As part of the demo, I had to create a calculated field, and when I brought up the New Field dialog an audience member suggested I create an InternalCalc field instead.

I’d never heard of an InternalCalc field at the time, so later I did some research into what they are. In FireDAC they do everything a normal Calculated Field does, but in addition, you can define the value using the DefaultExpression property of the field, rather than having to write an OnCalcFields event handler.

Read On…

LiveBindings : How to treat an Integer field as a Boolean?

I had a question recently from someone, and it seemed a common enough requirement that I thought the solution might be worth sharing.

Let’s say you’ve got a database that has an Integer column which is really used as a Boolean. Zero for False, One for True. Further, for whatever reason, you can’t change the DB structure. How do you display this column to the end user as a boolean, so that they can use a Checkbox column in a grid, a TSwitch control, or similar to edit it? Read On…