Skip to content

Instantly share code, notes, and snippets.

@mohan43u
Created June 21, 2015 04:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mohan43u/464ce1b5c83021a4b119 to your computer and use it in GitHub Desktop.
Save mohan43u/464ce1b5c83021a4b119 to your computer and use it in GitHub Desktop.
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