# Desktop on second monitor is opened AFTER invokeLater

**URL:** <https://forum.inductiveautomation.com/t/desktop-on-second-monitor-is-opened-after-invokelater/62898>\
**Category:** Ignition\
**Tags:** scripting, ignition80, vision\
**Created:** [August 11, 2022, 1:52am UTC](https://forum.inductiveautomation.com/t/desktop-on-second-monitor-is-opened-after-invokelater/62898 "2022-08-11T01:52:08Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [August 11, 2022, 12:24pm UTC](https://forum.inductiveautomation.com/t/desktop-on-second-monitor-is-opened-after-invokelater/62898/2 "2022-08-11T12:24:47Z")

</div>

Since your function is clearly using waits for external operations to happen, it is blocking the GUI thread. Ignition can't perform UI operations like opening desktops and popups (or anything else) while your "#do stuff" is hogging the foreground thread.

In general, sleeping or waiting in the UI thread is forbidden. { It's usually a bad idea in other contexts too. }

Ignition's client is an event-driven system (because Java Swing is event driven). Events need to execute to completion in a fraction of a second. Any waiting needed must be implemented with timer events and/or timer components and/or asynchronous threads.

If you choose that last, see this topic for the restrictions on what those can do:

> [@Update GUI via Asynchronous thread](https://forum.inductiveautomation.com/t/update-gui-via-asynchronous-thread/9666/3):
>
> Since this sort of thing pops up often, I created a set of wrappers that simplify this stuff, and allows you to directly use functions in your script modules. The wrappers take care of stuffing the arguments you supply into a temporary fuction’s default argument. For your case, try assignLater(). Nick’s example becomes: # In a script module in your project: import shutil def fileTransfer(label): path = system.file.openFile() newPath = "F:\NewFolder" shutil.copy2(path, newPath) sh…

---

_[View the full topic](https://forum.inductiveautomation.com/t/desktop-on-second-monitor-is-opened-after-invokelater/62898)._
