C++ Code: #include #include #include const double SPLIT = 0.01; const int COUNT = 200; const double PI = 3.14159265; const int INTERVAL = 300; int main() { DWORD busySpan[COUNT]; DWORD idleSpan[COUNT]; int half = INTERVAL / 2; double radian = 0.0; for (int i = 0; i < COUNT; i++) { busySpan[i] = (DWORD)(half + (sin(PI * radian) * half)); idleSpan[i] = INTERVAL - busySpan[i]; radian += SPLIT; } DWORD starttime = 0; int j = 0; while (true) { j = j % COUNT; starttime = GetTickCount(); while (GetTickCount() - starttime <= busySpan[j]); Sleep(idleSpan[j]); j++; } return 0; } ---------------------------------------------- Visual Basic Code: Option Explicit Private Declare Function GetTickCount Lib "kernel32" () As Long Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long) Private Const SPLIT As Double = 0.01 Private Const COUNT As Long = 200 Private Const PI As Double = 3.14159265 Private Const INTERVAL As Long = 300 Sub Main() Dim busySpan(COUNT) As Long Dim idleSpan(COUNT) As Long Dim half As Long half = INTERVAL / 2 Dim radian As Double Dim i As Long For i = 0 To COUNT - 1 busySpan(i) = half + (Sin(PI * radian) * half) idleSpan(i) = INTERVAL - busySpan(i) radian = radian + SPLIT Next i Dim starttime As Long Dim j As Long While (True) j = j Mod COUNT starttime = GetTickCount() While (GetTickCount() - starttime <= busySpan(j)) Wend Sleep (idleSpan(j)) j = j + 1 Wend End Sub