Fix a bug when a thread was trying to update the UI