I need to put some ListView populate code in a thread. For the simple case, this thread should not run twice. When I want to issue a new thread the previous needs to stop, whatever did.
EDIT 1
The scenario is the following.
I have a textual filter above the ListView. On textchange I call a populateList() method.
The problem is that the code can take longer as it uses SQL LIKE
syntax on a larger database.
Until this runs, the user cannot type in nothing. So there are sever hang-outs while you type in "abc", you get to type "c" after 10 seconds only.
So I have in mind to issue the populateList() method in a Thread and allow the user to quickly type in something more. The longer the text the slower takes the SQL query. In the "abc" situation if you type "a" code goes behind and runs the query, but meanwhile if the user pressed "b" I want to stop the execution of the "a" thread, and issue a new one, now using "ab"... and so on with the "c".
EDIT 2
Still looking for more answers.