title: How can I make a background worker thread set to Single Thread Apartment?
body: <p>I am creating an automated test running application.  In this part of the application, I am working on a polling server.  It works by constantly polling the web server to determine when a new automated test should be run (for nightly automated runs of our GUI application).</p>
  
  <p>When the polling server sees a request, it downloads all the information necessary and then executes the test run in a background worker.  The problem is that part of the test run has OLE, COM, and other calls (for example, <code>Clipboard.Clear()</code>) that occur in the background worker thread.  When one of these calls occurs, the following exception occurs:</p>
  
  <blockquote>
    <p>Current thread must be set to single thread apartment (STA) mode before OLE calls can be made. Ensure that your Main function has STAThreadAttribute marked on it.</p>
  </blockquote>
  
  <p>How can I mark a background worker thread as single thread apartment?  The Main call in my Program.cs obviously already has that attribute.</p>