q55x8x / Peronality-Creator

Sort of DevEnvironment for teaseAI personalities
4 stars 1 forks source link

TreeView search not working also search algorithm creates heavy load #39

Closed q55x8x closed 9 years ago

q55x8x commented 9 years ago

Haven't looked that much inside of why it doesn't filter anything or how we could improve it with e.g. incrementally removing treeNodes from the tree as the user types. But I will try some more things tomorrow.

png2 commented 9 years ago

If it's easier you can just select the first node matching the search and have a button got "next" and "prev" occurrence. Of course you also have to open all the parent nodes to make that node visible if it is not

That would probably be much more efficient and probably more usable than hiding the nodes

q55x8x commented 9 years ago

I have redone the search a bit simpler in 149409d210b4b6223bb335b18cdd646e1ae8ec98 but still even with O(N) we are a bit unresponsive :/

q55x8x commented 9 years ago

UI is now responsive during search see: 270d31465508504504f245b1968455b31a869ddc The layout actually took the most time to execute so I suspended it while searching and adding things to the tree.

png2 commented 9 years ago

You probably need to do the tree search in a separate thread (you can probably parallelize it too) and update the UI only when you are done to avoid UI freezes

The search should be that long as the tree isn't that large and we are only looking for the node names but that should help

The way I would do it :

On trigger search :

  1. Display "search in progress msg somewhere"
  2. Start search in a separate thread
  3. Each time I find an occurrence store it in a concurrent List
  4. When the search thread is done, highlight the first node of the list
  5. When the user want the next/previous occurrence, look for it in the list

If the tree change while a search is active :

  1. Restart the search thread if possible using another concurrent list
  2. Find the currently highlighted node in the new list
  3. Swap the lists and move the cursor keeping track of the currently highlighted element to the right place
q55x8x commented 9 years ago

I tried multiple approaches on multithreading but I haven't learned a lot about it specifically until now and so I don't have that much experience in context synchronizations.

The new c# task class makes synchronizing with the UI context a lot easier but only allows aborting tasks with cancellation tokens but I never had to use them.

Using the old way (Threads) produces a lot of overhead you have to write to synchronize properly. I tried that yesterday but haven't found a way to abort the search thread without causing the UI context to mess up completely and crash.

I will try a bit more regarding this topic and at least add an indicator that a search is currently taking place until filtering has finished but I can't promise that I will be able to make the search in a separate thread very soon. But I don't think that the search is currently the most important thing as I got it to work with at least very little unresponsiveness (see: 270d31465508504504f245b1968455b31a869ddc)

q55x8x commented 9 years ago

I think with 96476c4ac418bb5d6c518c67d7581cab8a609f7a this can now be closed