Attached is a dumb application that utilizes CreateThread(). It has examples of other NI issues that I have, but the snippet gives a one-shot example of a thread that I used.
- I dont have hand-shaking in this thread, it just gets created, processed, and then exits. You may want some hand-shaking in your thread, so you don't exit while your thread is still active.
- good luck...
static DWORD WINAPI reset_thread(
LPVOID parameter) /* in: thread data */
{
char buf[1024];
time_t present_time; /* Present time from time() function */
struct tm * converted_time = NULL; /* Time converted for use in strftime*/
time(&present_time);
converted_time = localtime(&present_time);
strftime(buf, 1023, "%H:%M:%S ", converted_time);
SetCtrlVal( untitledID, PANEL_STRING, buf );
return 0;
} // end reset_thread
int CVICALLBACK getCurrentTime (int panel, int control, int event,
void *callbackData, int eventData1, int eventData2)
{
if (event == EVENT_COMMIT)
{
HANDLE thread = NULL; /* Power-down thread handle */
thread = CreateThread(NULL, 0, reset_thread, NULL, 0, NULL);
}
return 0;
}