asp.net - in .NET, How do I set STAThread when I'm running a form in an additional thread? -
I am running a form in a second thread. If I am Ctrl-C to copy the text to the clipboard, I get an exception, "Before the OLE call, the current thread should be set to a single thread apartment (STA). (Using the clipboard OLE
>[STAThread] Private Zero MyFormThreadproc (Object O) {form = new MyForm (); Application.Run (form);}
When you make a thread, call it before starting the method. You can not do this for thread threads threads. For example:
thread Thread = new thread (thread action); thread.SetApartmentState (ApartmentState.STA); thread.Start ();
Comments
Post a Comment