Send Email non-responsive UI thread detected

Hi Team,
i come accross issue with Send email. I am currently have ignition vision 8.1.14 running on windows server 2019.
I am trigging the button action from designer which send the email to me. Currently each time i am pressing the button. It freeze the designer for 5-10seconds and then shows error on output console:

Error on Output Console:
[EDT-Watchdog-1] INFO edt-watchdog - Non-responsive UI thread detected. Stack saved at ‘C:\Users\mg.ignition\cache\gwlocalhost_8088\C0\NonResponsiveEdt-2022-03-09_083926.json’

Code on button action:

This code sends an HTML-formatted email to multiple recipients, including a cc, with no attachments,

using an smtp server defined in the Gateway.

subject = “data”
sender = “email@xx.co.nz”
body = “

This is a big header


body += “And this text is red”
recipients = [“Myemail@xx.co.nz”]
cc_recipients = [“Myemail@xx.co.nz”]
smtp_server = “EmailNotificationProfilename”
system.net.sendEmail(smtpProfile=smtp_server, fromAddr=sender, subject=subject, body=body, html=1, to=recipients, cc=cc_recipients)

i will attached the file with this topic.

NonResponsiveEdt-2022-03-09_083926.json (64.7 KB)

You are making a call to a gateway to send an email on your behalf, which is not bounded time-wise, from a Vision button. Vision button scripts, like all component events, runs in the java Swing foreground thread. Doing any long-duration (seconds) action on the foreground thread will block the user interface. In prior versions of Ignition, it could freeze indefinitely.

You need to learn to use system.util.invokeAsynchronous() to run your email send operation on a background thread, and report a notification back to your user at the end. Start here:

1 Like