Przemysław Czerpak wrote: > > one using nStartTime because time difference was calculated once at > startup. > The optimal code should make sth like: > nStopTime := IIF( nTimeout > 0, hb_milliSeconds() + nTimeOut * 1000 : 0 > ) > [...] > WHILE .T. > [...] > IF nTimeOut <= 0 .OR. hb_milliSeconds() >= nStopTime > EXIT > ENDDO > ENDDO > > It eliminates unnecessary calculations and hb_milliSeconds() calls. > > >
if nTimeout < 0 (indicates never timeout), the loop should continue. this is what I have [...] nStartTime := hb_milliSeconds() nTimeOut *= 1000 nTotWritten := 0 DO WHILE nTotWritten < Len( cString ) .AND. ; ( nTimeout <= 0 .OR. ( hb_milliSeconds() - nStartTime ) < nTimeout ) [...] if (nTimeout = 0) .or. ( hb_milliSeconds() < nStartTime ) // if the clock was moved back. DLST exit endif ENDDO because of DLST I'm also using a patched hb_idleSleep() proc myhb_idleSleep( ntimeOut ) local nStartTime if nTimeout > 0 nStartTime := hb_milliSeconds() nTimeOut *= 1000 do while ( hb_milliSeconds() - nStartTime ) < nTimeOut hb_IdleState() if hb_milliSeconds() < nStartTime exit ENDIF enddo else hb_IdleState() endif what do you think of it? Best Regards, Abe -- View this message in context: http://n2.nabble.com/Wrong-hbsms-tp4660463p4674270.html Sent from the harbour-devel mailing list archive at Nabble.com. _______________________________________________ Harbour mailing list (attachment size limit: 40KB) Harbour@harbour-project.org http://lists.harbour-project.org/mailman/listinfo/harbour