LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Using LabVIEWSMTPClient.lvlib to send emails freezes all my loops because the DLL calls are running on the UI thread

Using Labview 2021.

 

My project (that I inherited 5 years ago) has a lot of loops doing a lot of things, so when something freezes the entire application, it causes problems. For several years I've had issues with various bits of code running on the UI thread (root loop?) causing all the loops to pause momentarily which, when you're doing simultaneous data acquisitions, is a problem. Some have been easy to find and fix, some not. This one I hadn't ever witnessed and put the pieces together till yesterday.

 

When a problem occurs where we need a person to intervene to fix, we send emails out. Yesterday I was fixing and testing an unrelated bug that caused an email to go out, and saw everything freeze up when we sent said email. I checked several machines to see if it was happening everywhere, and it was. Dug into the problem and lo and behold it is LabVIEW's own SMTP library that's causing the issue. Dig in more and find that some (not all) of the DLL calls are set to "run in UI thread" instead of any thread. My understanding of this setting is that you should only run in any thread if the DLL is "threadsafe". The fact that only some of the calls made from the DLL are set to UI thread makes me think its a bug.

 

I guess what I'm looking for is for someone to confirm my logic above, and maybe give some guidance on options. I went ahead and changed all the DLL calls to be "any thread" and that immediately solved the specific freezing bug, but I am worried that the DLL isn't thread safe and it could cause future unforeseen issues. The only other option I see is finding some other DLL that is thread safe and use that in place of LabVIEW's SMTP library. Quick google search didn't fill me with a lot of confidence on finding a theadsafe specific DLL either. I guess option three is developing my own theadsafe SMPT DLL.

 

I'm a mostly self taught developer with experience in C, C#, and Labview. While I've been doing software development for over a decade now and am very confident in my skills, I do have holes in my knowledge. Root loop issues in particular are something I've observed for years but only recently have really understood, so if anyone has any guidance on my issue, it would be appreciated.

0 Kudos
Message 1 of 1
(217 Views)