To copy something to the clipboard in Windows (at least in .NET as far as I know) it has to be done on a separate thread that is in STA Mode. One example I have used is this.
Thread thread = new Thread(() => Clipboard.SetText(s.Trim()));
thread.SetApartmentState(ApartmentState.STA); //Set the thread to STA
thread.Start();
thread.Join();
Why do I have to do all of that instead of being able to just call:
Clipboard.SetText("text")
Best Answer
In a word, legacy.
In the article Why is STAThread required?, we're told:
Said another way, communication with operating system components like the Clipboard are handled through COM and that requires changing the apartment state of the thread by using an STA thread.