I have a function like :
public static Task<string> MakeAsyncRequest(string url, string contentType)
{
LogMe (TAG, url);
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
request.ContentType = contentType;
request.Method = WebRequestMethods.Http.Get;
request.Timeout = 200000;
request.Proxy = null;
Task<WebResponse> task = Task.Factory.FromAsync(
request.BeginGetResponse,
asyncResult => request.EndGetResponse(asyncResult),
(object)null);
return task.ContinueWith(t => ReadStreamFromResponse(t.Result));
}
So,how to set timeout for this tasK?
For example after 10 sec this task cancelled and toast say "Connection timeout"
I am a beginner in C#
Please assist.