For async to work properly, you must run the GLib MainLoop.  MainLoop is where 
your async closure for test_function.begin() is called.  It's where all 
callbacks are scheduled, actually.

The only reason this works is that in the case of DO_YIELD you stash the 
test_function.callback and then call it back.  That's why you're seeing "End 
callback called 1".

A better way to do this is to (a) get rid of ext_callback and (b) call "new 
GLib.MainLoop().run()" right before the "return 0" in main().  Without actually 
modifying the code (i.e. I'm doing this off the top of my head), that should 
work.

-- Jim

On Mon, Oct 22, 2012 at 2:47 PM, rastersoft <ras...@rastersoft.com> wrote:

-----BEGIN PGP SIGNED MESSAGE----- 
Hash: SHA1 

Hi all: 

I was working with async methods, and found something odd: if I call an 
async method, but, for whatever reason, I never call YIELD inside, the 
end callback function is never called. 

I attach an example: by compiling it with 

valac -D DO_YIELD -o test_async test_async.vala --pkg=gio-2.0 

will do a YIELD inside the async function. But when compiled with 

valac -o test_async test_async.vala --pkg=gio-2.0 

will not. In the former case you can see how "End callback called 1" is 
printed, because the callback for the end is called; but in the later, 
it's not printed. 

Is that a bug? If not, why does it work that way? 

Thanks. 

- -- 
Nos leemos 
RASTER (Linux user #228804) 
ras...@rastersoft.com http://www.rastersoft.com 

-----BEGIN PGP SIGNATURE----- 
Version: GnuPG v1.4.11 (GNU/Linux) 
Comment: Using GnuPG with Mozilla - http://www.enigmail.net/ 

iEYEARECAAYFAlCFvwEACgkQXEZvyfy1ha/m+QCfQzIoKObEBhWIO8mwCPtbjBNI
9I8AoJ2kNDrIRYqRsHFCk4sb6eN/pPyC 
=yUo1 
-----END PGP SIGNATURE----- 


_______________________________________________
vala-list mailing list
vala-list@gnome.org
https://mail.gnome.org/mailman/listinfo/vala-list

Reply via email to