I have a backgroundWorker thread running. At the end I update the UI, minimize the app & change the icon.
I tried to minimize the app in middle, but then the UI wasn’t updated, nor the icon was changed. Thread was executed but this part wasn’t done.
Can’t the UI get updated when the app is minimized ? If can, where I may be going wrong.
UPDATED :
@Daniel, YesI am aware of it. And when the task is done I call ProgressChanged is called and finally RunWorkerCompleted is also called. BUT when I minimize the app in middle, the components like Label’s aren’t changed. Button text is changed, but it hangs/stucks – button doesn’t work any longer. MY point is : If app is minimized during executing DoWork, then when ProgresChanged & RunCompleted is called or not. If called then why certain components aren’t changed. NOTE: If I don’t minimize in middle, then everything works perfectly fine.
You can only update the UI from the UI thread. The
ProgressChangedandRunWorkerCompletedevents are run on the UI thread, theDoWorkevent is not. This means, if you want to update your UI from aBackgroundWorkerwhile it is running, you need to do it in theProgressChangedevent handler.