Jure

Jure

  • NA
  • 863
  • 395.6k

Multithreading and function recursion

Sep 6 2010 3:44 AM
I haven't done multi-threading before, so I need a bit of help with this.
I have a form with a button. When user clicks on a button for the first time, a recursive function is called. When a certain condition in the function is true, I want the function to wait where it's at for the next button click.

An example:
void ButtonClick(object sender, EventArgs e)
{
if (running)
{
//notify the thread (the recursive function) to continue
}
else functionCall(0);
}

void functionCall(int num)
{
if (num % 2 == 0)
{
displaySomething();
//wait
}
functionCall(num + 1);
}


How would I do this?

Answers (7)