Updating ui from thread c Webcam porno chat totalmente gratis
So far so good, but sometimes it’s necessary to update the UI from this background thread.
If you ever tried to access an UI element from a background thread, you have already noticed that an exception is thrown.
The code below (from the previous article) would execute a long running task which in this case counts to 5,000,000.
As the task was running, on a set interval, the UI would be updated.
Sometimes it is not necessary to update the user interface that quickly. Send is a synchronous operation and will wait for an answer or action completed from the call, where as Post is asynchronous where it makes the call to the UI thread and continues without waiting for a reply.
In this example it wouldn’t appear to make much difference which of the 2 you use, but we have used Post as we do not require to wait for a reply as we are just posting some data to be shown on the screen.
This effectively decoupled the running of the task from the updating of the UI.
But for some reason my application just hangs, nothing being written it just hangs. But my suspicion is that even though you're using (you say) a separate thread for the async processing, your Click event handler doesn't return right away but instead waits for the processing to complete.
The code is much simpler to see what’s going on, but the behaviour is slightly different.
In this example, the code similarly counts upto 5,000,000 and updates the UI label.
This is another simple example that will help you to make your applications more responsive.
Although this example used Winforms as that is the space I am in at the moment, it is just as relevant for WPF too.