# Thread safety of Vision Client Event Timer Script

**URL:** <https://forum.inductiveautomation.com/t/thread-safety-of-vision-client-event-timer-script/116172>\
**Category:** Ignition\
**Tags:** vision\
**Created:** [June 26, 2026, 2:19pm UTC](https://forum.inductiveautomation.com/t/thread-safety-of-vision-client-event-timer-script/116172 "2026-06-26T14:19:40Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![charles-eloi.lafond](https://avatars.discourse-cdn.com/v4/letter/c/85e7bf/32.png) [@charles-eloi.lafond](https://forum.inductiveautomation.com/u/charles-eloi.lafond)\
**Post date:** [June 26, 2026, 2:19pm UTC](https://forum.inductiveautomation.com/t/thread-safety-of-vision-client-event-timer-script/116172/1 "2026-06-26T14:19:40Z")

</div>

Hello,

I have a Vision Client Timer script, and I'm wondering if it's thread-safe.

The script automatically logs out admin users after either 10 minutes of total activity or 1 minute of inactivity. For inactivity, it displays a warning 15 seconds before disconnecting the user.

I've read the documentation and forum posts about which operations are safe and unsafe to perform outside the EDT, but I'm still not sure whether my script is implemented correctly.

My main concern is whether calling `system.vision.openWindow()` and `system.vision.closeWindow()` from the timer script is safe, or if those calls should be executed on the EDT with `system.vision.invokeLater()` instead.

```python
def handleTimerEvent():
	# Disconnect Admin Users after 10 minutes of activity/ 1 minute of activity
	# Default Operator user is automatically logged back in	
	
	popupShown = "Popups/Logout Warning" in system.vision.getOpenedWindowNames()
	username = system.vision.getUsername()
	
	inactivity = system.vision.getInactivitySeconds()
	timeSinceLogin = system.date.secondsBetween(
	    system.tag.readBlocking(["[Client]LoginTime"])[0].value,
	    system.date.now()
	)
	

	if username == "Operator" or username is None:
	    if popupShown:
	        system.vision.closeWindow("Popups/Logout Warning")
	    return

	if timeSinceLogin > 600:
	    system.vision.closeWindow("Popups/Logout Warning")  
	    system.vision.switchUser("Operator", " ************")
	    return

	
	if inactivity >= 60:
	    system.vision.closeWindow("Popups/Logout Warning")	    
	    system.vision.switchUser("Operator", " ************")
	
	elif 45 < inactivity < 60 and not popupShown:
	        system.vision.openWindow("Popups/Logout Warning")
	
	elif inactivity <= 45 and popupShown:
	        system.vision.closeWindow("Popups/Logout Warning")

```

---

<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:** [June 26, 2026, 3:20pm UTC](https://forum.inductiveautomation.com/t/thread-safety-of-vision-client-event-timer-script/116172/2 "2026-06-26T15:20:56Z")

</div>

I don't recall what the timer's context is, but you can use [SwingUtilities.isEventDispatchThread()](https://docs.oracle.com/en/java/javase/11/docs/api/java.desktop/javax/swing/SwingUtilities.html#isEventDispatchThread()) to check it.

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [June 26, 2026, 3:28pm UTC](https://forum.inductiveautomation.com/t/thread-safety-of-vision-client-event-timer-script/116172/3 "2026-06-26T15:28:19Z")

</div>

These Vision scripting functions are safe to call regardless of thread, they check for and use the EDT if needed.

---

<div class="post-metadata">

**Author:** ![charles-eloi.lafond](https://avatars.discourse-cdn.com/v4/letter/c/85e7bf/32.png) [@charles-eloi.lafond](https://forum.inductiveautomation.com/u/charles-eloi.lafond)\
**Post date:** [June 26, 2026, 4:45pm UTC](https://forum.inductiveautomation.com/t/thread-safety-of-vision-client-event-timer-script/116172/4 "2026-06-26T16:45:34Z")

</div>

Thanks for the trick, the timer is not executed on the EDT
