Updating textbox from OnReceive(IAsyncResult ar)

I wish to update a text box from the OnReceive(IAsyncResult ar) of my C# server like so:

textBoxData.Text = sMessageToDisplay;

My rextbox does not get updated, why is this??  Has it something to do with the OnReceive being on a different thread or something??

Wanting2LearnManAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

deadlyDevCommented:
I assume from your question this is a web site?
If this is the case the reason for this is that the Response stream gets ended and flushed to the client at the end of the request on the main thread. If there is another thread busy operating which completes after the main thread has flushed the response data from the secondry thread will be lost.

If you would like to run many operations in paralel on the server, you could use the WaitAll method on the AutoResetEvent class, this will enable you to begin processing a number of threads, but wait at the end of the main thread until they are all finished processing.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.