Wing Posted May 14, 2007 Posted May 14, 2007 (edited) Well here is my problem i got a multi thread/form project. and if i try to use the clipboard on any other from then the "start form" i get a thread error.... sample code included. Tnx for any help!PlayWithForms.zip Edited May 14, 2007 by PlausiblyDamp Quote
Administrators PlausiblyDamp Posted May 14, 2007 Administrators Posted May 14, 2007 It looks as though there is some COM stuff going on behind the scenes when accessing the clipboard - one of the issues you need to be careful with is different threading models and how COM copes (or not) with them. When you know though the fix is easy... change the button click event in your form1 to the following and it should work. private void button1_Click(object sender, EventArgs e) { ParameterizedThreadStart p = new ParameterizedThreadStart(Run); Thread t = new Thread(p); t.SetApartmentState(ApartmentState.STA);//set the correct threading model and all is good. t.Start(new Form2()); } Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.