Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jun 17th, 2012  |  syntax: None  |  size: 0.70 KB  |  hits: 10  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. How to run the application continously without hanging in background
  2. public void Button1_Click(System.Object sender, System.EventArgs e)
  3.     {
  4.         if (Button1.Text == "Start")
  5.         {
  6.             Timer1.Interval = 5000;
  7.             Timer1.Enabled = true;
  8.             Button1.Text = "Stop";
  9.         }
  10.         else if (Button1.Text == "Stop")
  11.         {
  12.             Timer1.Enabled = false;
  13.             Button1.Text = "Start";
  14.         }
  15.     }
  16.        
  17. public void Timer1_Tick(System.Object sender, System.EventArgs e)
  18.   {
  19.   var bgw = new BackGroundWorker();
  20.   bgw.DoWork += new DoWorkEventHandler(bgw_DoWork);
  21.   }  
  22.  
  23. void bgw_DoWork(object sender, DoWorkEventArgs e)
  24.   {
  25.   // Put you try-catch block here.
  26.   }