1
Answer

loop time

nick van Alst

nick van Alst

16y
2.1k
1
hello,

i'm having the following problem with my application:
i need to check it for incomming tcp requests, but it get stuck if there aren't any of them. i need something to stop the loop after 5 seconds.
this is my code:
while (true)
{
Console.Write("Waiting for a connection... ");
TcpClient client = server.AcceptTcpClient(); <-- here it just waits till there is someone who wants to connect.
Console.WriteLine("Connected!");
}

how can i solve this??
i know i need to do somehing with the while but what??
thx!!

Nick
Answers (1)