Thread safety of Vision Client Event Timer Script

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.

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")

I don't recall what the timer's context is, but you can use SwingUtilities.isEventDispatchThread() to check it.

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

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