B4R Question pause loop every 'n' counts

Discussion in 'B4R Questions' started by Mostez, Mar 17, 2019.

  1. Mostez

    Mostez Active Member

    Hello,
    I have this loop, which sends data from SD card to serial stream, I would like to pause the loop for about 100 ms - every 10 K bytes of data(at 10 K, 20 ,30K etc..), to let the other device clear the buffer before receiving next 10 K. any ideas.

    Thanks

    Code:
    Do While counter < size
                
    Dim read As Int =  SD.Stream.ReadBytes(Buffer, 0Min(Buffer.Length, size - counter))
                
    If read = 0 Then
                    success = 
    False
                    
    Exit
                
    End If
                counter = counter + read
                
    ' I Want to pause the loop 100ms here every 10k, before sending data 

                StreamSource.Write2(Buffer,
    0,read)
    Loop
     
  2. Erel

    Erel Administrator Staff Member Licensed User

    If you are not worried about blocking the program while it waits then use:
    Code:
    If Counter > Target Then
     Delay(
    100)
     Target = Target + 
    10000
    End If
     
  3. Mostez

    Mostez Active Member

    Thanks Erel
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice