setting timeout of a post in c#

Im trying to specify a timeout length of the following code.  Like if it takes more than 7 seconds, then stop processing or something, and throw a TimeoutException or something.  Does anybody know how to do that?
public string ProcessHttpPost(string url)
        {
            WriteValuesToTrace();
 
            WebClient client = new WebClient();            
            byte[] bResponse = client.UploadValues(url, "POST", this.Values);
            return Encoding.ASCII.GetString(bResponse);
 
        }

Open in new window

LVL 8
rodmjayAsked:
Who is Participating?
 
Praveen VenuConnect With a Mentor Technical Project ManagerCommented:
client.Timeout = 60000; //(Required timeout milliseconds)
0
 
bedanandCommented:
On the web.config file you can change the timeout duration on seconds.


0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.