views:

57

answers:

1

Hi all, I'm having some problems with a small ircbot i'm writing. Basically I connect to the server using a tcpclient in a seperate class, which also runs on its own thread. I want to display the server text in a richtextbox control on the main form.

The big issue I'm having is that as soon as the text starts coming in the whole application freezes. I started by trying to use an event that the main form would listen for and then add the text to the textarea, which works up untill the text stops coming and then the app freezes again.

I've also tried using a delegate with the same result. Has anyone else had this issue ?

A: 

Essentially only the UI thread is allowed to access the form. There are many ways to communicate between the threads. One easy solution is to put a timer on the form and poll for updates from the TCPClient thread periodically.

Eric Nicholson
isn't Raising The Event as good as a timer since it should only fire when the event occurs?
No, because the event code runs on a background thread, while the timer's event is going to run on the UI thread.
Eric Nicholson
Is it possible the issue could be caused by the textarea being on a form which its self is a child of an MDI form ?