title: I need a thread keeping running forever. which method is best?
body: <p>I need to a background long running thread from the asp.net application.
  BTW,the method fetches something from external data source period and maybe exception happens, I provide some ways to fullfill this task, please advice which way is best, please advice if there is better way.</p>
  
  <p>Way1=Looping when exception happens.</p>
  
  <pre><code>    static void LongRunningMethod()
      {
          do
          {
              try
              {
              //fetch something from external period and maybe exception happens.
              Thread.sleep(100000);
              }
              catch(Exception ex)
              {
                  //log exception..
              }
          } while (true);
      } 
  </code></pre>
  
  <p>Way2=Running the following method period by something like timer, and open a new thread when exception happens.</p>
  
  <pre><code>    static void LongRunningMethod()
      {
  
              try
              {
              //fetch something from external period and maybe exception happens.
              Thread.sleep(100000);
              }
              catch(Exception ex)
              {
                  //log exception..
              Thread T2 = new Thread(LongRunningMethod);
              T2.Start();
              }
  
      } 
  </code></pre>
  
  <p>Way3=Call itself when exception happens.</p>
  
  <pre><code>    static void LongRunningMethod()
      {
  
              try
              {
              //fetch something from external period and maybe exception happens.
              Thread.sleep(100000);
              }
              catch(Exception ex)
              {
                  //log exception..
                 LongRunningMethod();
              }
  
      } 
  </code></pre>