There is a button like below :
private void btnStartAdventure_Click(object sender, EventArgs e)
{
if (backgroundWorker5.IsBusy)
{
btnStartAdventures.Enabled = false;
lblStatusValueInAdventures.Text = "Canceling...";
backgroundWorker5.CancelAsync();
}
else
{
txtLogInAdventures.Text = string.Empty;
btnStartAdventures.Text = "Cancel";
lblUsersDoneCountValueInAdventures.Text = "---";
lblStatusValueInAdventures.Text = "Running...";
backgroundWorker5.RunWorkerAsync();
}
}
i want to call btnStartAdventure_Click event again after backgroundWorker_RunWorkerCompleted job!
so there will be a loop that never ends.
i put:
Thread.Sleep(3600000);
at the end of backgroundWorker_RunWorkerCompleted().
now what code should i use for call btnStartAdventure_Click again?
is Timer good for my purpose or not?
how can i prevent hanging and crashes by doing that job?
thanks in advance
To fire the
btnStartAdventure_Clickevent handler programmatically, you can callJust put that code in the end of the
backgroundWorker_RunWorkerCompletedevent.See this article for more information.