Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
async function using vala
#!/usr/bin/env vala
class Test.Async : GLib.Object {
public async string say(string sentence) {
GLib.Idle.add(this.say.callback);
yield;
return sentence;
}
public static int main(string[] args) {
Test.Async myasync = new Test.Async();
GLib.MainLoop mainloop = new GLib.MainLoop();
myasync.say.begin("helloworld",
(obj, res) => {
string sentence = myasync.say.end(res);
print("%s\n", sentence);
mainloop.quit();
});
mainloop.run();
return 0;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment