c# - Threading UI Update (not the invoke required question) -
I have a case where I get so many sockets coming requests. I would like to update the UI after 3 seconds The last socket request has arrived. If the socket arrives in the request and the last one was only 2 seconds earlier, then it should clean the UI update and start waiting for 3 seconds.
Note: Each socket request arrives at a different thread.
You can update the UI in three seconds with the interval (timer's property to your Set in the form) and whenever you receive a request, reset it.
Edit : On the further thinking, you should use one, which is less convenient then the timer. Timer is
but more lightweight, and fully thread-protected. In your callback, you have to call form.BginInvoke
to switch to the UI thread.
Every time you receive a request, you can timer.Change (3000, -1)
.
Comments
Post a Comment