[Vala] How to get return values from async methods



Hi folks,

I was struggling a bit with the right approach to get return values from
async methods if called from a sync method. The approach would be to
register a callback in a closure like:

public string [] get_results () {
        string [] results = {};
        some_async_method.begin (parameters, (obj, res) => {
                results = some_async_method.end (res);
        });
        
        return results;
}

as obviously some_async_method is not finished yet, I'm getting an empty
results array. 
How do I make sure that the results are properly returned after the the
async method has finished?

thanks,

-- 
tomw <tomw ubilix com>




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]