0
我需要將此代碼發現here轉換爲它的vb.net equivqlent,任何人都可以幫助我嗎?將htmlweb委託從c#轉換爲vb.net
摘錄代碼
/// <summary>
/// Represents the method that will handle the PreRequest event.
/// </summary>
public delegate bool PreRequestHandler(HttpWebRequest request);
//And they call that delegate right before making the GetResponse call:
if (PreRequest != null)
{
// allow our user to change the request at will
if (!PreRequest(req))
{
return HttpStatusCode.ResetContent;
}
}
HttpWebResponse resp;
try
{
resp = req.GetResponse() as HttpWebResponse;
}
//So all you have to do is assign a delegate to PreRequest and set your timeout within that delegate:
var web = new HtmlWeb();
web.PreRequest = delegate(HttpWebRequest webRequest)
{
webRequest.Timeout = 4;
return true;
};
var doc = web.Load("http://www.msn.com/");
你試過這個嗎? (嘗試一下) –