29 lines
590 B
Vala
29 lines
590 B
Vala
|
async double async_method() {
|
||
|
SourceFunc callback = async_method.callback;
|
||
|
|
||
|
double result = 0;
|
||
|
|
||
|
ThreadFunc<void*> run = () => {
|
||
|
stdout.puts("Thread is running!\n");
|
||
|
result = 3.14;
|
||
|
stdout.puts("Thread stopped!\n");
|
||
|
Idle.add((owned)callback);
|
||
|
return null;
|
||
|
};
|
||
|
|
||
|
new Thread<void*>("debugging thread name", run);
|
||
|
yield;
|
||
|
|
||
|
return result;
|
||
|
}
|
||
|
void main() {
|
||
|
MainLoop mainloop = new GLib.MainLoop();
|
||
|
async_method.begin((obj,res) => {
|
||
|
var result = async_method.end(res);
|
||
|
stdout.puts(@"async_method.callback()\nResult = $result\n");
|
||
|
mainloop.quit();
|
||
|
}
|
||
|
);
|
||
|
mainloop.run();
|
||
|
}
|