Crossthread operation

G

Guest

I have a richtextbox that acts like a console with information on the status
of the server I am creating. I spawn new threads for each connection that is
created and would like to write the status to the console. When I try to do
that right now it gives me the error "Cross-thread operation not valid:
Control 'rtbConsole' accessed from a thread other than the thread it was
created on." Thanks in advance!s
 
O

Oliver Sturm

Benny said:
I have a richtextbox that acts like a console with information on the status
of the server I am creating. I spawn new threads for each connection that is
created and would like to write the status to the console. When I try to do
that right now it gives me the error "Cross-thread operation not valid:
Control 'rtbConsole' accessed from a thread other than the thread it was
created on."

Well, this is not allowed, as you might have guessed :) One article
that explains this very well is Jon Skeet's Threading overview, here's
the link to the relevant page:

http://www.yoda.arachsys.com/csharp/threads/winforms.shtml

You might want to read the rest of it (switch to other pages at the
bottom) if you do a lot of threading in your app.



Oliver Sturm
 
G

Guest

your form should use only the main thread
you can create as many treads as u think u need but each time u wanna write
to your richtextbox u should do it with your main thread that handle the gui
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top