mercredi 1 avril 2015

Code in button click c# happens after the function finishes

I have some simple C# code that is triggered on a Button Press. The button press first clears some ListBoxes, then changes the text of a label, and then calls a function.



private void button1_Click(object sender, EventArgs e)
{
listBox1.Items.Clear();
listBox2.Items.Clear();
listBox3.Items.Clear();
listBox4.Items.Clear();
label5.Text = "Getting links...";
process(url);
label5.Text = "Finished";
}


But the Lists are cleared and the label is changed after process() is finished executing. This ruins the purpose as I'm changing the label so that the user is aware that some action is taking place. How can I make the initial label change before the function process() finishes?


Aucun commentaire:

Enregistrer un commentaire