title: Threading Practice with Polling
body: <p>I have a C# application that has to constantly read from a program; sometimes there is a chance it will not find what it needs, which will throw an exception. This is a limitation of the program it has to read from.</p>
  
  <p>This frequently causes the program to lock up as it tries to poll. So I solved it by spawning the 'polling' off into a separate thread. However watching the debugger, the thread is created and destroyed each time. I am uncertain if this is typical or not; but my question is, is this good practice, or am I using the threading for the wrong purpose? </p>
  
  <pre><code>ProgramReader
  { 
    static Thread oThread;
    public static void Read( Program program )
    {
      // check to see if the program exists
      if ( false )
        oThread = new ThreadStart(program.Poll);
      if(oThread != null || !oThread.IsAlive )
        oThread.Start();
    }
  }
  </code></pre>
  
  <p>This is my general pseudocode. It runs every 10 seconds or so. Is this a huge hit to performance? The operation it performs is relatively small and lightweight; just repetitive.</p>