How to use Thread / BackgroundWorker / Timer / AutoResetEvent or something else to force function f to wait / suspend / pause until the button is clicked by user.
public Form1()
{
InitializeComponent();
if(f())
MessageBox.Show("returned");
}
bool b=false;
private void button1_Click(object sender, EventArgs e)
{
//do something
b=true;
}
bool f()
{
//what to put here
//should be here only after b==true
return true;
}
I could compare it should work like Console.ReadKey pauses the function until gets the input.