Question

I have three image buttons on my main screen. For the button click I have written an event handler in which a web request is sent and the returned response is bound to datagrid. These things are working fine but while these processes are running, the button remains in the pressed state until the grid is populated.

How can I overcome this issue?

Was it helpful?

Solution

It remains blocked because you're using the UI thread to request data, which can take a long time to complete, hence the thread is blocked and cannot therefore update the button. There is only one thread to update the UI, which works like a queue.

You can use a background worker to fix that, have a look here:

How to use WPF Background Worker

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top