tags:

views:

188

answers:

1

Hi there guys! :D

I'm trying to have my application download the source code of a website and filter out the information that I need to pull on my application.

Everything is fine and dandy however the UI freezes until my application finishes downloading the source code of the site.

If there is anywhere I can get help, this has got to be the place. :)

Here's the code that makes me cry:

public void LoadPlayersOnline()
    {
        WebClient WebClientClass = new WebClient();

        string SiteSource = WebClientClass.DownloadString("http://forums.chronic-domination.com/");
        int AlliancePos = SiteSource.IndexOf("Alliance");
        string AlliancePlayers = SiteSource.Substring((AlliancePos + 14), 3);

        label5.Text = AlliancePlayers;
    }
+2  A: 

You will most likely want to use DownloadStringAsync. Then implement the events on it http://msdn.microsoft.com/en-us/library/system.net.webclient%5Fevents%28VS.80%29.aspx DownloadCompleted.

http://msdn.microsoft.com/en-us/library/system.net.webclient.downloadstringasync%28VS.80%29.aspx

jwendl
After reading the link provided I can't seem to figure out how to use the "DownloadStringCallback"? What is that? Thanks for the help.
Sergio Tapia
DownloadStringCallback can be any call back method that has an argument of DownloadStringCompletedEventArgspublic static void DownloadStringCallback2 (Object sender, DownloadStringCompletedEventArgs args){ // If the request was not canceled and did not throw // an exception, display the resource. if (!args.Cancelled Console.WriteLine (textString); }}
jwendl
Bad stack overflow... Just check out the example on http://msdn.microsoft.com/en-us/library/system.net.downloadstringcompletedeventargs(VS.80).aspx
jwendl