Hello Leonardo,

2011/9/29 Leonardo Ferreira Fontenelle <[email protected]>:
> I'm trying to port a small Python GTK+ application to Vala. Overall, I
> have succeeded, with some very interesting performance gains. But in
> some cases the search may take a few seconds to finish, while the
> application reads data from the disk. I tried using an async method to
> keep the user interface responsive, but it didn't work: until the search
> is completed, the user can't even move the cursor in the text entry
> widget. What am I missing?

Simply declaring your method async doesn't make it automatically use
async i/o. If I understand correctly, the function that takes time is
get_matches, you need to either execute it in another thread, using
something like:

Gee.TreeSet<int32> matches = null;
Thread.create<void>(() => {
    matches = get_matches (words);
    Idle.add (search.callback);
});
yield;

or make get_matches (and possibly other methods it calls) async, and
use the async versions of the i/o functions you call (assuming you use
GIO), and call it like:

Gee.TreeSet<int32> matches = yield get_matches();

HTH,
Abderrahim
_______________________________________________
vala-list mailing list
[email protected]
http://mail.gnome.org/mailman/listinfo/vala-list

Reply via email to