Clipboard Task error
<p>Here is the error I am getting:</p>

<blockquote>
  <p>An exception of type 'System.Threading.ThreadStateException' occurred
  in System.Windows.Forms.dll but was not handled in user code</p>
  
  <p>Additional information: 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>I am trying to assign a value to the clipboard within a <code>Task</code>. When I execute the code I get the error above.</p>

<p>Here is the clipboard code:</p>

<pre><code>static public class ClipBoard
    {
        static private string _data = string.Empty;
        static public Semaphore ClipBoardSemaphore = new Semaphore(1, 1);

        static public void SetData(string data)
        {
            Clipboard.Clear();  //error here
            Clipboard.SetDataObject(data, true);
            _data = data;
        }

        static public string GetData()
        {
            return _data;
        }
    } 
</code></pre>

<p>As you can see the error happens when the clipboard is cleared. 
Here is the code that invokes the Task:</p>

<pre><code>for (int i = 0; i &lt; zom.Count; i++)
{
     Task t = Task.Factory.StartNew(zom[i].Process);
     t.Wait();
}
</code></pre>
