I want to implent a "type to start search"-feature like the google search in my program. After every type my program starts a new search thread and kills the old one.
But now I want to wait for example 2 seconds before the search thread does actually starts. Something like this:
Countdown countdown = new Countdown();
countdown.set_action_after_x_secons(2sec, do_search);
private void SearchEntry_search_changed(){
countdown.reset_time(); //resets time to 2 seconds again
actual_search = SearchEntry.get_text();
}
private void do_search(){
// actual search here
}
I want to avoid to spawn to many useless threads. What is the best way to do this in Vala?
Thanks to @andlabs! GLib.Timeout was the keyword. For solution see here: