Hello, I work on an windows universal app project and I receive data from a server but when I use the await LoadAsync method and all the data has been received the method
enters in
an infinite loop ,so I want to make a timeout, to do this I use a cancellationTokenSource but when the timeOut occur it close the socket, is it normal ?
CancellationTokenSource cts = new CancellationTokenSource();
try
{
cts.CancelAfter(2000);
await reader.LoadAsync(sizeof(UInt16)).AsTask(cts.Token);
cts.Cancel();
}
catch (TaskCanceledException a){
Debug.WriteLine("error");
}