WebClient下载字符串(几个字符页面)太慢了

Bar*_*zek 4 c# performance webclient downloadstring

我正在尝试从URL下载字符串.不幸的是,它很慢.

这是我的代码:

    // One of these types for two bad solutions anyway
    // byte[] result = new byte[12];
    // string result;
    using (var webClient = new System.Net.WebClient())
    {
        String url = "http://bg2.cba.pl/realmIP.txt";
        //result = webClient.DownloadString(url); // slow as hell
        //webClient.OpenRead(url).Read(result, 0, 12); // even slower
    }
Run Code Online (Sandbox Code Playgroud)

这需要大约4-5秒,这对我来说似乎非常不合适......

此网址的内容为IP

 XX.YYY.ZZ.FF
Run Code Online (Sandbox Code Playgroud)

Bar*_*zek 7

固定,很抱歉我把这个问题放在这里,但是......这里是工作代码

string result;
using (var webClient = new System.Net.WebClient())
{
    webClient.Proxy=null;
    String url = "http://bg2.cba.pl/realmIP.txt";
    result = webClient.DownloadString(url);
}
Run Code Online (Sandbox Code Playgroud)

只需将Proxy设置为null即可