LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

ProcessSystemEvents & callback functions

Hello.

 

I have a question about the ProcessSystemEvents() and callback functions. If I have the following "strange" callback function with the follwoing code inside:

 

int func(...) {

 

  while(true) {

   ProcessSystemEvents();

  }

}

 

Could this code create a crash in the underlying run-time lib (cvirte.dll etc), with to many calls to ProcessSystemEvents?

And will this code stop any other callback function from execution, since we are in an infinite while loop?

 

Best regards,
Christian G.

 

 

 

 

 

0 Kudos
Message 1 of 4
(3,088 Views)

The answer is "no" to both questions: processSystemEvents has been designed exactly to permit handling user and system events that normally would not be processed in situations like your loop.



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 2 of 4
(3,084 Views)

Hello! Thank you for the quick answer, it is very much appreciated.

 

If the callback function above is set at an intervall of say 100 times per second, how will the system react to that? Since the callback function is never terminated, will the system still keep on generating call to this never ending callback? Could this make the system crash?

 

Best regards,

Christian G.

0 Kudos
Message 3 of 4
(3,082 Views)

A fuction like that should be called only once, if this is what you intend. While sitting in the loop, ProcessSystemEvents permits the system to react to events like the user pressing a button or something like this. You must explicitly avoid dangerous events like calling the function again and again, as well as all user actions that can cause problems (like modifying critical parameters while the function is running, improperly exiting the program and so on). To obtain this you may either disable unwanted buttons on the GUI or set a global flag 'system running' tested on all callbacks and functions to protect the system from unwanted operations.



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 4 of 4
(3,079 Views)