LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Problem with timer control callback

I have a control that triggers timer this way: 

      

case CONTROLSET_ESAUTOPWR:
      

      PwrDmd_saved = 0;
      GetCtrlVal(PanelControlset[i],CONTROLSET_ESAUTOPWR,&Es_auto_power[i]);
      if (Es_auto_power[i])
      {
       SetCtrlAttribute (PanelMenus,MENU_ESAUTOPWR_TIMER,ATTR_ENABLED,TRUE);
      }
      else
      {
       SetCtrlAttribute (PanelMenus,MENU_ESAUTOPWR_TIMER,ATTR_ENABLED,FALSE);
      }
      break;

The timer has it's own callback function that runs every 2 sec.

When I enable the timer control the callback function runs.

But when I disable the timer control the callback function doesn't stop.

So to stop this function I must exit the program. It's prohibitive to exit the program such way.

 

What is wrong in my example? How can I stop the timer control callback execution?

0 Kudos
Message 1 of 2
(2,974 Views)

I see no evident reason for this misbehaviour: are you sure the "else" case is actually executed? If I'm not wrong you have a callback associated to several controls with a switch on the control ID: in this structure care must be taken in panel handle and control id, to be sure that you are addressing the correct control both when retrieving its value in GetCtrlVal and when setting the timer enable attribute. Placing a breakpoint and checking all these values may help you in debugging this situation.



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 2
(2,967 Views)