LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Timed Function

Solved!
Go to solution

I'm working on an application that needs to run some code for a series of time intervals set by the user. My implementation currently is to have the user set the time through text entry boxes and have a function update the times in these and check for when to move on. This function triggers on pushing a start button. Unfortunately, the code stops on the click of the start button as it seems to be waiting for the code to finish executing before it allows any further inputs.

 

Is there a "right" way to do this? Maybe something with multithreading or a pre-built timer application?

0 Kudos
Message 1 of 3
(1,377 Views)
Solution
Accepted by topic author csulliva

You are on the right way speaking about timers: place a timer control on your panel, set it to disabled, put your code in the timer callback and run the program. When the user inputs the required time, set the ATTR_INTERVAL attribute of the timer to this value, next enable the timer with ATRT_ENABLED attribute and you'll have your timed function up and running!

 

You can search timer.cws sample project to have a reference application for the use of timers (Help >> Find Examples... menu function, next enable Search tab and enter "Timer" in the search box)



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?
Message 2 of 3
(1,314 Views)

Hi

 

If you want to run the code inside the timer callback in a seperate thread, you can use the Asynchronous Timer Library. The NewAsynchTimer() creates the timer. 

 

Jan

0 Kudos
Message 3 of 3
(1,272 Views)