I recent development I have been working on uses a TTreeview control. The underlining classes that relate to the nodes of the control get updated and I reflect the state of the class as dynamic colour of the node text. This state change can happen every few seconds so I wanted to refresh the treeview at least every couple of seconds.
I read a few articles on how to do this but found the treeview would flicker. The best solution I found was simple, when I wanted to refresh just simply call the 'invalidiate' method, at first this did not work until I set the doublebuffered property to true and now it works really well.
Showing posts with label method. Show all posts
Showing posts with label method. Show all posts
Thursday, 30 April 2015
Tuesday, 9 April 2013
How to correctly free a thread
There are 2 ways to free a thread, below are both, but my favourite way is to explicitly free the thread as I may want to reference something after the thread is terminated, but before it is freed.
while not Terminated do
3) When you want to free the thread do something like:
FThread.Terminate;
FThread.Terminate;
Explicitly free the thread
1) Set the 'FreeOnTermiate' property to false, this can be done when your thread class is created.
2) In the execute procedure check for the terminate property e.g.
while not Terminated do
begin
// execute code
end;
3) When you want to free the thread do something like:
FThread.Terminate;
FThread.WaitFor;
FreeAndNil(FThread);
Easier way to free the thread
1) Set the 'FreeOnTermiate' property to true.
2) When you want to free the thread just call:
FThread.Terminate;
Subscribe to:
Posts (Atom)