I want to wait to a timer finish and then return from a function. I tried this:
while(timer1.Enabled)
{
Application.DoEvents();
}
return value;
But it didn't work and the function returned before the timer really finished. Here's the full function:
System.Windows.Forms.Timer timer1 = new System.Windows.Forms.Timer();
int[] foo()
{
do_something1();
int[] some_value;
timer1.Interval = 1000;
timer1.Tick += new EventHandler(delegate(object o, EventArgs ea)
{
if (browser.ReadyState == WebBrowserReadyState.Complete)
{
timer1.Stop();
baa(some_value);
}
});
timer1.Start();
while (timer1.Enabled)
{
Application.DoEvents();
}
return some_value;
}