code here:
var localadd = IPAddress.Any;
var server = new TcpListener(localadd, 6300);
server.Start();
while (true)
{
var client = server.AcceptTcpClient();
Task.Run(() => ThreadProc(client));
}
// The cpu cost is as normal as usual.
The code above could run in expectation,But! When i move the client variable out of the while loop,then it will make whole CPU usage nearly full. code here:
var localadd = IPAddress.Any;
var server = new TcpListener(localadd, 6300);
server.Start();
var client = server.AcceptTcpClient();
while (true)
{
Task.Run(() => ThreadProc(client));
}
// The cpu cost nearly 100%!!!
Could somebody else explain for this thing?