I have want to run a function asynchronously to prevent UI freezing. Here the the button click event.
private void btnEncrypt_Click(object sender, EventArgs e)
{
// Create new Vigenere object instant
cryptor = new Vigenere(txtPassword.Text, txtBox.Text);
// Run encryption async
Task<string> T = new Task<string>(cryptor.Encrypt);
T.Start();
}
Now I want the following function to be called when the Task T
finishes with it's return value as a parameter like this:
private void Callback(string return_value)
{
txtBox.Text = return_value
// Some other stuff here
}
How to achieve this?