#elif SINGLE_THREADED_POLLING_APPROACH uint elapsedTime = (uint)(Environment.TickCount - startTime); if (elapsedTime >= 5000) { break; } // Stay open for 20 seconds. This must be within while(true) and not outside.