
Untitled
By: a guest on
Jun 17th, 2012 | syntax:
None | size: 0.70 KB | hits: 10 | expires: Never
How to run the application continously without hanging in background
public void Button1_Click(System.Object sender, System.EventArgs e)
{
if (Button1.Text == "Start")
{
Timer1.Interval = 5000;
Timer1.Enabled = true;
Button1.Text = "Stop";
}
else if (Button1.Text == "Stop")
{
Timer1.Enabled = false;
Button1.Text = "Start";
}
}
public void Timer1_Tick(System.Object sender, System.EventArgs e)
{
var bgw = new BackGroundWorker();
bgw.DoWork += new DoWorkEventHandler(bgw_DoWork);
}
void bgw_DoWork(object sender, DoWorkEventArgs e)
{
// Put you try-catch block here.
}