Saturday, July 12, 2014

Smart Mobile Studio 2.1 (beta 1) is out!

If you need to write software for phones/browsers/node.js/microcontrollers, you should check out the new Smart Mobile Studio 2.1 (beta 1). The list of new and fixed features is much too long to list here so I’ll just focus on the most important additions.

  • Integrated debugger!

    image
  • Dockable IDE with support for multiple layouts.

    image
  • Configurable keyboard shortcuts.

    image
  • Split view mode shows code and design side-by-side.

    image
  • Support for with statement in a clean, non-Delphi way.
    with p := something do begin
      // do anything with p
    end;
  • Optimizations and bug fixes in the compiler.
  • Built-in browser uses Chromium CEF3.

Thursday, July 10, 2014

Incrementing Progress Bar from a ForEach Loop

A deceptively simple question – how do you update a progress bar from a ForEach loop – popped up on the Google+ OmniThreadLibrary community. The implementation turned out to be quite tricky so I created an example (55_ForEachProgress) which is now part of the OmniThreadLibrary SVN repository.

The starting point was a simple Parallel.ForEach loop which I further simplified in the demo.

  Parallel
.ForEach(1,
CNumLoop)
.Execute(
procedure (const task: IOmniTask; const i:
integer)
begin
// do some work
Sleep(1
);

// update the progress bar - how?
end
);

We cannot simply update the progress bar from the ForEach executor as that code executes in a background thread and one must never ever access VCL GUI from a background thread! It is also no good to send “please update” Windows messages to main thread as Parallel.ForEach is by default blocking – it waits for all workers to stop working – and messages won’t be processed during ForEach execution.