• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 553
  • Last Modified:

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??

1 Solution
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.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now