Psst.. new poll here.
Psst.. new forums here.
Microsoft is blocking us again (TY IP Reputation!) so just use oauth login instead. :)
Paste
Pasted as Plain Text by greenman55 ( 11 years ago )
using Gtk;
public int test(Button button)
{
Thread.usleep(5000000) ;
button.label = "You thank" ;
return 0 ;
}
int main (string[] args) {
Gtk.init (ref args);
var window = new Window ();
window.title = "First GTK+ Program";
window.border_width = 10;
window.window_positi
window.set_default_size (300, 70);
window.destroy.connect (Gtk.main_quit);
var butt Button.with_label ("Click me!");
button.clicked.connect (() => {
//button.label = "Thank you";
run_in_thread<int>(()=> { return test(button);}) ;
});
window.add (button);
window.show_all ();
Gtk.main ();
return 0;
}
public delegate G TaskFunc<G> () throws Error;
public async G run_in_thread<G> (owned TaskFunc<G> func) throws Error {
SourceFunc resume = run_in_thread.callback;
Error err = null;
G result = null;
new Thread<void*> (null, () => {
try {
result = func ();
} catch (Error e) {
err = e;
}
Idle.add ((owned) resume);
return null;
});
yield;
if (err != null) {
throw err;
}
return result;
}
Revise this Paste