Using RChart in Threads

Problem If using threads to display or update data in RChart, RChart does not display all data, or even does not display at all ("disappears").
Applies To BDS, Delphi, and C++Builder
Solution There seems to be a bug in the run-time libraries which keeps RChart from updating when using it in a separate thread. In order to solve this you have to perform some "magic" during the initialization of the thread. You must not start the thread automatically but start it explicitely after its creation. The following lines of code will fix the problem:
interface

....
type
  TMyThread = class(TThread)
                private
                  { Private declarations }
                protected
                  procedure Execute; override;
              end;
var
  MyThread : TMyThread;
....


implementation

....
MyThread = TMyThread.Create(true); // create the thread but do not start it
MyThread.Execute;                  // start the thread
....

 


Last Update: 2006-10-19