Cross-thread operation not valid

Page 1 of 1

3 Replies - 740 Views - Last Post: 28 November 2009 - 06:21 PM Rate Topic: -----

#1 Medic873  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 78
  • Joined: 16-November 08

Cross-thread operation not valid

Post icon  Posted 28 November 2009 - 05:50 PM

Okay i am using a back ground worker along with a copy text box function that a user fill out in the windows form

But it wont work

private void BackGroundWorker1_DoWork(object sender, DoWorkEventArgs e)
		{
Textbox1.Select(0, 100);
Clipboard.SetDataObject(Textbox1.SelectedText, true);

		}


but it wont allow it to copy becuase "Cross-thread operation not valid: Control 'CreatorGmailAccount1' accessed from a thread other than the thread it was created on."

so how can i make it allowed to copy

Thank you

Please help this isnt homework thank you

Is This A Good Question/Topic? 0
  • +

Replies To: Cross-thread operation not valid

#2 Renagado  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 117
  • View blog
  • Posts: 388
  • Joined: 14-June 09

Re: Cross-thread operation not valid

Posted 28 November 2009 - 06:08 PM

Try passing the text from TextBox1 as an argument to the bg worker. On the other hand, why did you choose to use a second thread? It doesn't seem completely needed for this, since selecting some text and copying it to the clipboard isn't really a lengthy operation.
Was This Post Helpful? 0
  • +
  • -

#3 JackOfAllTrades  Icon User is offline

  • Saucy!
  • member icon

Reputation: 6091
  • View blog
  • Posts: 23,606
  • Joined: 23-August 08

Re: Cross-thread operation not valid

Posted 28 November 2009 - 06:10 PM

You're making some sort of spammer/bot, aren't you?

Edit: Why yes, I believe you are, based on your clpservice. Hmmm...
Was This Post Helpful? 0
  • +
  • -

#4 PsychoCoder  Icon User is offline

  • Google.Sucks.Init(true);
  • member icon

Reputation: 1642
  • View blog
  • Posts: 19,853
  • Joined: 26-July 07

Re: Cross-thread operation not valid

Posted 28 November 2009 - 06:21 PM

I'm with @JackOfAllTrades in thinking this is some sort of spammer/bot. I'm closing this thread until you can verify or prove it is otherwise as that is not something we support here :)
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1