Skip to main content
added 27 characters in body
Source Link
Jamal
  • 34.9k
  • 13
  • 133
  • 237

2 bugs:

I. this value should be other way around else, thread never sleeps (always sleep a negative number )

Original: l_lMin = elapsed_time - l_oTimer.duration;
Fix: l_lMin = l_oTimer.duration - elapsed_time;

II. m_lMinSleep = 0; is wrong, in minimum calculation, 0 or any other positive number, 0 is always be minimum, and that is why, you need to set it to max long value, or to change type to unsigned with -1 value

  1. This value should be the other way around; thread never sleeps (always sleep a negative number):

    Original:

     l_lMin = elapsed_time - l_oTimer.duration;
    

    Fix:

     l_lMin = l_oTimer.duration - elapsed_time;
    
  2. m_lMinSleep = 0; is wrong. In the minimum calculation, 0 or any other positive number, 0 is always the minimum. That is why you need to set it to max long value, or change the type to unsigned with -1 value.

2 bugs:

I. this value should be other way around else, thread never sleeps (always sleep a negative number )

Original: l_lMin = elapsed_time - l_oTimer.duration;
Fix: l_lMin = l_oTimer.duration - elapsed_time;

II. m_lMinSleep = 0; is wrong, in minimum calculation, 0 or any other positive number, 0 is always be minimum, and that is why, you need to set it to max long value, or to change type to unsigned with -1 value

2 bugs:

  1. This value should be the other way around; thread never sleeps (always sleep a negative number):

    Original:

     l_lMin = elapsed_time - l_oTimer.duration;
    

    Fix:

     l_lMin = l_oTimer.duration - elapsed_time;
    
  2. m_lMinSleep = 0; is wrong. In the minimum calculation, 0 or any other positive number, 0 is always the minimum. That is why you need to set it to max long value, or change the type to unsigned with -1 value.

Source Link

2 bugs:

I. this value should be other way around else, thread never sleeps (always sleep a negative number )

Original: l_lMin = elapsed_time - l_oTimer.duration;
Fix: l_lMin = l_oTimer.duration - elapsed_time;

II. m_lMinSleep = 0; is wrong, in minimum calculation, 0 or any other positive number, 0 is always be minimum, and that is why, you need to set it to max long value, or to change type to unsigned with -1 value