3

1 バイトのデータをdownloadStringAsync()ダウンロードする際に 10 秒間 UI がフリーズしないように実装しようとしています。ただし、ダウンロードが完了しても、 を使用したかのように UI がフリーズしています。downloadString()

これが私のコードです:

    public void loadHTML()
    {
            WebClient client = new WebClient();

            // Specify that the DownloadStringCallback2 method gets called
            // when the download completes.
            client.DownloadStringCompleted += new DownloadStringCompletedEventHandler(loadHTMLCallback);
            client.DownloadStringAsync(new Uri("http://www.example.com"));
            return;
    }

    public void loadHTMLCallback(Object sender, DownloadStringCompletedEventArgs e)
    {
        // If the request was not canceled and did not throw
        // an exception, display the resource.
        if (!e.Cancelled && e.Error == null)
        {
            string result = (string)e.Result;

            // Do cool stuff with result

        }
    }
4

1 に答える 1