Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

When should I use VirtualTree's BeginSynch vs BeginUpdate?

We've started using VirtualTreeView v5.5.3 with Delphi7 since 1 year and love it!

We would like to use the full potential of the component, but there is only a little information about the BeginSynch method in the help file.

When should BeginSynch + EndSynch be used compared to BeginUpdate + EndUpdate?

Which one should be nested into the other?

What methods can be used in which case? (Sort, ScrollIntoView, MoveTo, NodeHeight, isVisible[], ... ) to group manipulations before painting to speed up the app?

like image 445
SzakiLaci Avatar asked Sep 04 '19 04:09

SzakiLaci


1 Answers

To my understanding they have different, almost opposite purposes, and for your use case you would need BeginUpdate.

BeginUpdate is typically called when you want to do a lot of updates, and you don't want redrawing etc to happen during that process. Many controls, including TListBox and TDBGrid, have this possibility to speed up bulk updates.

BeginSynch is related to events, especially the OnChange event. The VirtualTreeView can fire the OnChange event with some delay when you set the ChangeDelay property to a value higher than 0. This also means that you may miss some events. If you make two changes in rapid succession, you may only get one event, or you may get the event later than desired. BeginSynch will start a synchronous mode that fires the OnChange event immediately after (in sync with) the change being made, overriding the ChangeDelay property. Starting this sync mode is easier than saving the value of the ChangeDelay property and restoring it afterwards.

So in a way, you could say that BeginUpdate and BeginSync are almost opposites of each other, in terms of speed, but really it's just about what your usecase is. For your case ("grouping manipulations") you would definitely use BeginUpdate.

The documentation on BeginSynch could be a bit more clear in this regard. It refers to BeginUpdate because it's a similar kind of mechanism (entering some kind of update mode, with a correlating EndSomething method), while actually it should refer to ChangeDelay which it is functionally related to. It's also interesting that the 'Send feedback' link at the bottom of the documentation is not actually a link...

like image 161
GolezTrol Avatar answered Nov 16 '22 01:11

GolezTrol