Fix deadlock issue if file is opened on GUI thread.