04-11-2012 04:47 AM
Hi,
I have been using LabWindows CVI 9.0 since a few years now and I have seen a problem that didn't blocked me until now.
My LabWindows Software freezes, the code is no longer executed, when I hold a click on the interface, on a string for example.
The problem is that I use a device that emits data continuously on a COM port. When I decide to drag the software window or simply hold a left click on the interace the software stop acquiring data from the COM callback and my software misses data.
Do you have a solution for this problem ?
Thank you
04-11-2012 06:21 AM - edited 04-11-2012 06:25 AM
I never observed this clicking on controls, but dragging a window or even simply keeping the muse clicked on its title bar is the typical user action that can block a single-threaded program.
The only solution I know in this case it so split the program in multiple threads, moving the relevant part (in your case all COM stuff) in threads other than the main one, tipically dedicated to handle the GUI.
See the documentation on multithreading that is installed on your system; alternatively, you may want to look at the asynchronous timers. Documentation on both can be foun on this site also.
04-12-2012 06:31 AM
HI Penou,
In fact it is a good idea using multiple Threads to avoid this kind of behavior.
Maybe you are using ProcessSystemEvents to handle events, on the same main thread.
If it is the case, when ProcessSystemEvents handles an event that starts a tracking loop, such as the user pulling down a menu, ProcessSystemEvents does not return until the tracking loop completes. In the case of pulling down a menu, the tracking loop does not complete until the user dismisses the menu.
You have several inforrmations about ProcessSystemEvents here.
Regards,
Rémi D.
National Instruments France
04-12-2012 07:41 AM
Hello Remi,
just out of curiosity, does this applies also to GetUserEvent? I have observed sometimes sudden program freezees in some applications of mine but was never able to narrow them down to a specific condition: I wonder if this can be a possible reason for them (I am sometimes using this method in case of small option panels I need to handle user action on, e.g. parameters to select some data to print and so on).
04-12-2012 08:38 AM
Hi RobertoBozzolo,
The same apply with the GetUserEvent.
From the LabWindows/CVI Help (GetUserEvent), you can get this information.
Bye,
Rémi D.
National Instruments France
04-12-2012 09:10 AM - edited 04-12-2012 09:11 AM
Thanks, that explains something.
Which actions exactly start a tracking loop? I mean, in my application I have no menu (or at least the I am handling a panel without menu shown with InstallPopup) so which other action / event / something can issue a tracking loop? I see a few seconds program freeze immediately after opening or closing the panel. A separate thread continues running.