how to cancel an awaiting task c#
Posted
by
user1748906
on Stack Overflow
See other posts from Stack Overflow
or by user1748906
Published on 2012-11-22T22:09:58Z
Indexed on
2012/11/22
22:59 UTC
Read the original article
Hit count: 145
I am trying to cancel a task awaiting for network IO using CancellationTokenSource, but I have to wait until TcpClient connects:
try
{
while (true)
{
token.Token.ThrowIfCancellationRequested();
Thread.Sleep(int.MaxValue); //simulating a TcpListener waiting for request
}
}
any ideas ?
Secondly, is it OK to start each client in a separate task ?
© Stack Overflow or respective owner