Measurement Studio for VC++

cancel
Showing results for 
Search instead for 
Did you mean: 

Timers for Visual C++

What is the recommended equivalent for the CVI timer control under Visual C++? I could use a worker thread I suppose. Just wondering if you had any suggestions. Thanks,

Grant
Grant M. Johnson
Project Engineer
LECO Corporation
0 Kudos
Message 1 of 2
(3,490 Views)
The equivalent of the CVI timer control in MFC applications is the CWnd::SetTimer/CWnd::KillTimer facility where you handle WM_TIMER messages. Look at MSDN for help on these.

This timer posts messages to your main window. As such, your callback will not execute while your application's main thread is busy.

If you require more deterministic notification, I recommend that you use the Measurement Studio CNiTimer class. This class uses the Windows OS multi-media timer objects to provide you high-resolution notifications in a system thread. The class help for CNiTimer in Measurement Studio Reference describes the various ways you can install callbacks to receive notification on the multimedia timer thread. One more tip: if you are going to call into a Measur
ement Studio ActiveX control inside your timer callback, you must first call ::CoInitialize or ::CoInitializeEx in the thread.

David Rohacek
National Instruments
Message 2 of 2
(3,490 Views)