Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

VCL component not processed in the background

liptehlipteh Member Posts: 4
Dear all

I've been programming in C++ Builder for a number of years and generally found it to be a great product. However, there is one perennial problem with the executable when run outside the Builder IDE as a stand-alone exe.

The program involves very intensive matrix computations at certain stages, and when this is happening, the VCL components such as TLabel and TImage just freeze even though they are Refresh()ed prior to the matrix computations. The program just continues to run fine however, only you cannot see the components being updated as should be the case until the computation ends.

The problem described above does not occur when the program is run within the IDE environment.

Could anybody please kindly shed light on the phenomenon? Many thanks beforehand.

Cheers

Lip

Comments

  • LundinLundin Member Posts: 3,711
    Heavy calculations shouldn't be done in the main GUI process, they should be executed in a separate thread to avoid problems with graphic updates and the program "locking up".

    I would advise you to read up on the topic of multi-threading, every programmer needs to know about it.

    (Especially nowadays when CPUs have multiple cores and can perform "true" multitasking. Without a multi-threaded program, an additional CPU core won't improve program performance at all.)
  • liptehlipteh Member Posts: 4
    Thank you very much for a most useful advice!
  • liptehlipteh Member Posts: 4
    Sorry Lundin, I had misrepresented the problem, especially in the title where the word "background" is misleading. The matrix computations and the graphics update are not independent of each other, as they must follow each other in a loop. The graphics are updated based on the matrix computation results, and only after the graphics are updated, a new set of matrix computation follows. It is between these computations that, when run as a standalone executable file, the graphical display freezes. This problem does not occur when the program is run within C++ Builder IDE.

    I've tried creating a separate thread for the matrix computations, but it slows them down significantly irrespective of the thread priorities.

    When a separate thread was created for the graphics update instead with the computations being in the main thread, the display behaves in an unpredictable manner. Here I'm not referring to the program execution shuttling between threads in uncontrolled sequence, but to the fact that, at the end of the program, sometimes the final graphics output are displayed, sometimes not, even though exactly the same input and algorithm are involved. This inconsistency is observed when the program is test run a few times.

    Would you please kindly confirm if this is indeed a problem that can be solved with proper multi-threading? Thank you very much for your expert advice beforehand.

    Cheers

    Lip
  • liptehlipteh Member Posts: 4
    deleted deleted deleted
Sign In or Register to comment.