Task.Delay(-1, token) is creating a Task for every client that is running forever:
|
var cancellationTask = Task.Delay(-1, token); |
A quick and dirty workaround would be this:
private async Task<bool> DelayTask(CancellationToken token1, CancellationToken token2)
{
while (!token1.IsCancellationRequested && !token2.IsCancellationRequested)
{
await Task.Delay(100);
}
return true;
}
public async Task<TcpClient> WaitAnyTcpClientAsync(CancellationToken token)
{
var tokenToDispose = new CancellationTokenSource();
var cancellationTask = Task.Run(() => DelayTask(token, tokenToDispose.Token));
do
{
...
}
while (result == null);
tokenToDispose.Cancel();
}
Task.Delay(-1, token) is creating a Task for every client that is running forever:
FtpServer/src/FubarDev.FtpServer/MultiBindingTcpListener.cs
Line 121 in edfe7a7
A quick and dirty workaround would be this: