LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

can multithread async timer write in a list box on the main panel ??

Hallo,

I try to write with a mutithread async timer to a listbox on the main_panel, but nothing happens.
By compiling and running the program, no error appears.

the programm in a short version:

int main (....)
{
int panel;
...
panel = LoadPanel (0, "test.uir", PANEL);
InstallPopup(panel);
...
timerID = NewAsyncTimer (5.0, -1, 1, MyTimerFunction, NULL);
...
}


int MyTimerFunction (....)
{
int panel;
char output;
...

if (event == EVENT_TIMER_TICK)
{
panel = LoadPanel (0, "test.uir", PANEL); // without this line: "invalid control ID"
InsertListItem (panel, PANEL_LISTBOX, -1, OUTPUT, 0); //listbox value data type: char
}
return 0;
}



What's wrong here?

kind regards
Florian
0 Kudos
Message 1 of 6
(3,956 Views)
Your problem is the panel handle. As can be read in the on-line help for EventFunction parameter in NewAsyncTimer function, "The first parameter of the event function is reserved.", so the callback does not know the handle of the panel on which to operate.

You can set "panel" parameter in main function as global to the project and use the global variable in the timer callback. Look at the sample attached in which as async timer flashes a led on the main panel.

Roberto


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 6
(3,951 Views)
thank you,

I thought it would be a problem in this direction...

ok, now it works. thanks.

Florian
0 Kudos
Message 3 of 6
(3,949 Views)
Dear Roberto,
I have tried to compile yuor program in the CVI 6.0 and 7.1, but
I received error message:

Undefined symbol '_NewAsyncTimer' referenced in "AsyncT.C"

Sandor

Roberto Bozzolo wrote:
> Your problem is the panel handle. As can be read in the on-line help for EventFunction parameter in NewAsyncTimer function,

"The first parameter of the event function is reserved.", so the
callback does not know the handle of the panel on which to operate.

<br><br>You can set "panel" parameter in main function as global to the
project and use the global variable in the timer callback.

Look at the sample attached in which as async timer flashes a led on the
main panel.<br><br>Roberto
>
>
> AsyncT.zip:
> http://forums.ni.com/attachments/ni/180/15918/1/AsyncT.zip
0 Kudos
Message 4 of 6
(3,920 Views)
Dear Sandor,

to use the asyncronous timer (as well as all others .fp instruments shipped with CVI) you need either to add them to the Library (project window: Options >> Library options... item) or load them as an instrument (project window: Instrument >> Load... item).

In either case you must navigate till the directory into which the .fp file is located (usually \toolslib\toolbox) and double-click on the appropriate file (in case of the asyncronous timer will be "asynctmr.fp"). In case you have lodaded it into the Library you will need to restart CVI before you can use it, otherwise the tool is immediately active.


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 5 of 6
(3,913 Views)
Roberto,
Thank you for the suggestion, it is works!
Sandor

Roberto Bozzolo wrote:
> Dear Sandor,<br><br>to use the asyncronous timer (as well as all others .fp instruments shipped with CVI) you need either to add them to the Library (project window: Options >> Library options... item) or load them as an instrument (project window: Instrument >> Load... item).<br><br>In either case you must navigate till the directory into which the .fp file is located (usually <cvidir>\toolslib\toolbox) and double-click on the appropriate file (in case of the asyncronous timer will be "asynctmr.fp"). In case you have lodaded it into the Library you will need to restart CVI before you can use it, otherwise the tool is immediately active.
0 Kudos
Message 6 of 6
(3,887 Views)