I would like to use Sleep() with a means of varying the sleep duration. I have tried the code below, but get an error. Is there a way to use Sleep, or something similar, with a code set variable controlling the sleep duration? I have been using the Wait Sub below, but a forum search indicates that this is not good practice.
Regards
	
	
	
	
	
	
	
		
			
			
			
			
			
		
	
	
	
		
	
	
		
	
	
	
	
	
	
	
	
		
			
			
			
			
			
		
	
	
	
		
	
	
		
	
			
			Regards
			
				B4X:
			
		
		
		Dim Secs As Int
Secs = ( a variable depending on what is being processed. This is set earlier in code.)
Sleep(Secs * 1000)
	
			
				B4X:
			
		
		
		Sub Wait(Seconds As Int)
    'Sleep for defined seconds
    Dim Ti As Long
    Ti = DateTime.Now + (Seconds * 1000)
    Do While DateTime.Now < Ti
        DoEvents
    Loop
End Sub