visual c++ - OnTimer only repeating first function call -


Basically I have a program that has 6 sliders sending values ​​through a serial port, I'm dynamically using a timer. Resend these values ​​as they change by user. The problem I have is that the 6 functions called by my timer are behaving strangely, the first function calls the call, and continuously sends the signal, but the second 5 Only send signals later when the values ​​change the user. (I want to change the current value of each slider constantly, so that I'm sending it, that device does not come out, and the code is the same for them, but the timer already works properly). I was thinking that this was a known problem with timer or I am doing something wrong.

My timer is:

  Loop_Timer = SetTimer (1,50,0);   

... Zero Cessarial Port Dlg :: Onitimer (UINT Niedent) {write_1 (); // works as expected, without the constant user input, writes this function with Write_2 (); // These work only when they change, and stop sending later. Write_3 (); Write_4 (); Write_5 (); Write_6 (); CDialog :: OnTimer (nIDEvent); }

I've never used serial communication with MFC, but I do not think that The way to go to SetTimer is that those timers are very unbelievable when you set it to 50ms, then what exactly are you saying "do not tick more than 50ms", but it depends on the computer (and the system timer resolution ) Can be 50, 55, 500 or so on. Your app WM_TIMER messages have been reported every time the time is and there are no more messages in the message queue Therefore, if the user is carrying a mouse, the message will be "late" < P> Besides, I do not know how long those Write_X functions take, but you should not do long things in the timer handler, or you'll miss the ticks (which is probably happening).

He said, if you really need to send the position of the slider (or whatever you need to send), then you should get a way to do it continuously, depending on the timer No. I mean, how to send your data and complete your work, notify your app or sender thread, and start sending again. But I'm not sure how this should be done.

Comments

Popular posts from this blog

mysql - BLOB/TEXT column 'value' used in key specification without a key length -

c# - Using Vici cool Storage with monodroid -

python - referencing a variable in another function? -