Dear all,
How can I properly "populate" a Virtual Treeview in a background thread? It is discouraged to use AddNode, so my question is specifically about OnGetText and OnInitChildren.
My idea is to start a background worker thread in the OnExpanded event. The worker would have both the treeview and the node saved and could easily add the correct nodes after it has finished ... but this is discouraged.
In the "virtual" paradigma, I assume I should use ReinitNode and ReinitChildren instead. This is also not a problem, both treeview and node are known to the worker thread. OnInitNode would then fire again.
But now I have a couple of problems:
#1: How do I detect that the node had been initialized before and there is not need to run a new worker thread?
#2: Finally, when OnGetText and OnInitChildren fire, I do not have any reference to the background worker containing the data that were populated before. There can, of course, be multiple worker threads if the user expanded multiple nodes at once.
So, how do I properly do it?