You can set your request to timeout after 5 seconds.
See WebRequest.Timeout for full details.
If a timeout happens, an exception will be thrown that you should catch and properly handle.
Descendant classes signal a timeout by throwing a WebException with the Status field set to WebExceptionStatus.Timeout. When Timeout is set to Timeout.Infinite the descendant class does not time out.