Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6391929
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T03:44:54+00:00 2026-05-25T03:44:54+00:00

Basically I have a program that has 6 sliders that send a value through

  • 0

Basically I have a program that has 6 sliders that send a value through a serial port, I’m using a timer to dynamically resend these values as they are changed by the user. The problem I am having is that the 6 functions called by my timer are behaving strangely, the first function call works as it should, and continually sends the signal, but the other 5 called afterwards only send the signal when the values are changed by the user. (I want the current value of each slider resent constantly so the device I am sending it to doesn’t drop out, and the code for them is the same, but the timer only works properly with the first one). Was wondering if this was a known issue with the timer or I’m doing something wrong.

My Timer is:

Loop_Timer = SetTimer(1,50,0);

…

void CSerialPortDlg::OnTimer(UINT nIDEvent)
{
    Write_1(); //works as expected, continually writes from this function without user input
    Write_2(); // these only work when they are changed, and stop sending afterwards..
    Write_3();
    Write_4();
    Write_5();
    Write_6();
    CDialog::OnTimer(nIDEvent);
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T03:44:55+00:00Added an answer on May 25, 2026 at 3:44 am

    I’ve never done serial communication with MFC, but I don’t think that SetTimer is the way to go. Those timers are very unreliable. When you set it to 50 ms, what you are really saying is “tick no sooner than 50 ms”, but it can be 50, 55, 500, or whatever, depending on what’s the computer doing (and the system’s timer resolution). Your app will get WM_TIMER messages every time the indicated time has elapsed and there are no other messages in the message queue. So, if the user is moving the mouse, the message will be “late”.

    Apart from that, I don’t know how long do those Write_X functions take, but you should not be doing lengthy things in a timer handler, or you’ll miss ticks (which might be what’s happening).

    That said, if you really need continuous sending of the slider status (or whatever data you need to send) you should find a way to do it continuously, not based on a timer. I mean, find a way to send your data and when finished, notify your app, or sender thread, and start sending again. But I’m not really sure how it should be done.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

basically, I have a program that has a class to create a basic GUI,
I have a Java program that generates Java classes for my application. Basically it
I have a program that has this code : #include<stdio.h> main(){ int input; char
I'm having troubles getting this to work. Basically I have a python program that
I have some code that does custom drawing. Basically it is form fill program
I have a VB.Net program that will basically make a query to a remote
I have a program that has an array of pointers such as: INTLIST* myArray[countOfRows];
Basically, I want to have my program retrieve various variables from the hard drive
I have a gridview control in my c# program. Basically someone enters an email
I basically have a page which shows a processing screen which has been flushed

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.