LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Multithreading in multiple source files

Solved!
Go to solution

Hello everyone!

I have read the topics about working with multiple source files and multithreading as well, however i cannot manage to make the two work in my project.

There is an example program about multithreading, with a counter.

When you start the program the counter starts as well and when you push a reset button it is set back to 0 and starts counting again. 

I would like to do this with another source file but on the same user interface. It other numeric on the UIR starts counting as well, however i cannot reset it back to 0. I would like to know where i went wrong. I would appreciate any help, but i just put here the whole project in a zip file.


Thank you in advance!

0 Kudos
Message 1 of 2
(2,702 Views)
Solution
Accepted by topic author Kugelkopf

Hi,

 

The 1st counter thread has a counter variable named "counter" and the second thread has a counter variable named "numbering". If you haven't already noticed, you are resetting the value of only counter and not numbering.

int CVICALLBACK ResetCounter (int panel, int control, int event,
		void *callbackData, int eventData1, int eventData2)
{
	switch (event)
		{
		case EVENT_COMMIT:
			counter=0;
	SetCtrlVal (panelHandle, PANEL_NUMERIC, counter);
			break;
		}
	return 0;
}

Add numbering=0; in the above callback function. Another thing i have noticed is that , you are initiliasing the panelHandle in both files, which is not neccessary. Also its recommended to release the threads before you stop the program using quit callback. 

 

Best Regards

Deepu Jacob

-----------------------------------------------------------------------------------------------------------------------------
Waiting For the inner calling 🙂


0 Kudos
Message 2 of 2
(2,618 Views)