This is part of my code snippet.
I want to pass a callback function into test().
therefore, after calling the “del” delegate, the callback() can be trigger automatically?
Functions:
butOK_Click() //when click the button, disable it
test() //a wrapper function calling updateUI function
updateUI() // a long process function
callback() // a callback function enabling the button back
How can i do this?
Thanks
public delegate void updateUIDelegate(bool refresh);
public delegate void asyncCallback();
//...
void butOK_Click(object sender, EventArgs e) {
butOK.Enabled = false;
test();
}
public void updateUI() {
// long function....doing 10s
}
public void callback() {
butOK.Enabled = true;
}
public void test() {
updateUIDelegate del = new updateUIDelegate(updateUI);
del.BeginInvoke(null,null);
//??????????
}
Plesse, try the following:
Please also take a look at the following article: Calling Synchronous Methods Asynchronously