Created
June 21, 2015 04:53
-
-
Save mohan43u/464ce1b5c83021a4b119 to your computer and use it in GitHub Desktop.
async function using vala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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